Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

A little Powershell Help - Powershell - parse directory names on remote computers

$
0
0

I am trying to get the $names of the most current profiles on XP hosts by using get-childitem. Then for each name returned get the size of the desktop, my documents, and *.pst"

I pieced together the following which will only pull one computer from the list.  Trying to figure out how to loop this or put this all into the pipeline using foreach-object.

$computers = Get-Content c:\working7\aaa\pshell\copmputers.txt
foreach ($computer in $computers) {
$path = "\\$computer\c$\docume~1"
$names =Get-ChildItem -Path $path |
Where-object {$_.name -ne ("exmp1") -and $_.name -ne ("exmp2") -and $_.name -notlike ("*exmp3*") -and $_.name -ne ("exmp4")  -and $_.name -notlike ("*exmp5*") -and $_.name -ne ("exmp6") -and $_.name -ne ("all users") -and $_.name -ne ("exmp7") -and $_.lastwritetime -gt (Get-Date).adddays(-14)} | select-Object name
$newnames = $names.name }

foreach ($newname in $newnames) {
$FldSize = (Get-ChildItem "\\$computer\c$\docume~1\$newname\desktop" -Recurse | Measure-Object -Property length -Sum)
$FMB = "{0:N2}" -f ($FldSize.sum / 1MB) + " MB"
write-host   $newname  "desktop" $FMB

Any help with this is appreciated.  Thanks in Advance


Viewing all articles
Browse latest Browse all 15028

Trending Articles