header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Getting get-childItem to spill its guts
Last Post 26 Apr 2008 08:14 PM by RichS. 3 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
shatterstar6457User is Offline
New Member
New Member
Posts:2
Avatar

--
23 Apr 2008 05:58 PM  

hello everyone, my name is Danny and Im new on powershellcommunity.org and I was wondering if there was a way to get get-childItem to show its output to the screen while searching for files with a certain extension. Here's my code...

 

# This file was created with Powershell version 1.0 in mind
# On Monday, April 21, 2008  At: 1:32:15 PM
# Created By: Danny Ocean

# Preprocessor Directive(s)


# Variables
$strCurrentTime = Get-Date -Format "hh:mm:ss"

cls
write-host "Process started at: $strCurrentTime"
write-host "What directory would like to start searching for the files?"
$strStartDir = read-host

write-host "What file extension are we looking for mister?"
$strFileExt = read-host

write-host "Name and location of the output file"
$strOutFile = read-host

write-host "Currently Processing"
$Dir = get-childitem $strStartDir -include *strFileExt  -recurse
write-host "Finished Processing"

# $Dir |get-member
$List = $Dir
$List |ft fullname |out-file $strOutFile
# List | format-table name

And no, the -verbose parameter doesn't work, any help would be appreciated, thx in advance

 

valdezdjUser is Offline
New Member
New Member
Posts:62

--
23 Apr 2008 06:45 PM  
Try changing to:
$Dir = get-childitem $strStartDir -include "*$strFileExt" -recurse

Then at the bottom above $List = $Dir put $Dir

Not sure if that's what you are looking for?
shatterstar6457User is Offline
New Member
New Member
Posts:2
Avatar

--
26 Apr 2008 05:51 PM  

What I would like to do is to get get-childItem to output to the console and file, while processing matching files. tried Foreach-Object, but didnt work.

RichSUser is Offline
New Member
New Member
Posts:41
Avatar

--
26 Apr 2008 08:14 PM  
Try something like

get-childitem $strStartDir -include "*$strFileExt" -recurse | Tee-Object filelist.txt
Richard Siddaway
Microsoft MVP - PowerShell
UK PowerShell User group Leader
www.get-psuguk.org.uk
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer