![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | powershell equivalent of "DIR \\server\path /A:D /S /B" How can I do something like this within powershell. this is basically a directory listing showing only directories and is recursive. the /B makes it show only the direcotry paths, not any of the other directory information. Thanks! |
My System Specs![]() |
| | #2 (permalink) |
| | Re: powershell equivalent of "DIR \\server\path /A:D /S /B" Its long, but powerful. ls \\server\path -rec | ?{$_.PSIsContainer} | select FullName May I ask what you want this info for? Perhaps I can help with the end goal if this is not it. Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject BC> How can I do something like this within powershell. BC> this is basically a directory listing showing only directories and BC> is BC> recursive. the /B makes it show only the direcotry paths, not any of BC> the BC> other directory information. BC> Thanks! BC> |
My System Specs![]() |
| | #3 (permalink) |
| | Re: powershell equivalent of "DIR \\server\path /A:D /S /B" Thanks! that's awesome it's exactly what i'm looking for. Basically, I need to recursively check some network shares, then see if they contain folders with certain names (specifically, we have some weird corruption issues where files turn into folders, so i need to check if each of these containers have specific file extentions). I was using 'test-path', but was using a wildcard and therefore it's checking EVERY folder and taking a long time. I think getting a folder listing then checking the output of the GCI would make it run much faster. Basically what i need to do is: $count = 0 foreach ($user in $list) { $gci = GCI $homeroot\$user -rec | ?{$_.PSIsContainer} | select FullName #not real code below ![]() if ($gci contains ".xls" or ".doc") { #resume real code add-content $output $user $count = $count + 1 } } care to enlighten me on exactly how i could write that 'if' statement? ![]() "Brandon Shell [MVP]" wrote: Quote: > Its long, but powerful. > > ls \\server\path -rec | ?{$_.PSIsContainer} | select FullName > > May I ask what you want this info for? Perhaps I can help with the end goal > if this is not it. > > Brandon Shell > --------------- > Blog: http://www.bsonposh.com/ > PSH Scripts Project: www.codeplex.com/psobject > > BC> How can I do something like this within powershell. > BC> this is basically a directory listing showing only directories and > BC> is > BC> recursive. the /B makes it show only the direcotry paths, not any of > BC> the > BC> other directory information. > BC> Thanks! > BC> > > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: powershell equivalent of "DIR \\server\path /A:D /S /B" if (($gci -contains ".xls") -or ($gci -contains ".doc")) Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject BC> Thanks! that's awesome it's exactly what i'm looking for. BC> BC> Basically, I need to recursively check some network shares, then see BC> if they contain folders with certain names (specifically, we have BC> some weird corruption issues where files turn into folders, so i BC> need to check if each of these containers have specific file BC> extentions). I was using 'test-path', but was using a wildcard and BC> therefore it's checking EVERY folder and taking a long time. I BC> think getting a folder listing then checking the output of the GCI BC> would make it run much faster. Basically what i need to do is: BC> BC> $count = 0 BC> foreach ($user in $list) { BC> $gci = GCI $homeroot\$user -rec | ?{$_.PSIsContainer} | select BC> FullName BC> #not real code below ![]() BC> if ($gci contains ".xls" or ".doc") { BC> #resume real code BC> add-content $output $user BC> $count = $count + 1 BC> } BC> } BC> care to enlighten me on exactly how i could write that 'if' BC> statement? ![]() BC> BC> "Brandon Shell [MVP]" wrote: BC> Quote: Quote: >> Its long, but powerful. >> >> ls \\server\path -rec | ?{$_.PSIsContainer} | select FullName >> >> May I ask what you want this info for? Perhaps I can help with the >> end goal if this is not it. >> >> Brandon Shell >> --------------- >> Blog: http://www.bsonposh.com/ >> PSH Scripts Project: www.codeplex.com/psobject >> BC> How can I do something like this within powershell. >> BC> this is basically a directory listing showing only directories >> and >> BC> is >> BC> recursive. the /B makes it show only the direcotry paths, not any >> of >> BC> the >> BC> other directory information. >> BC> Thanks! >> BC> |
My System Specs![]() |
| | #5 (permalink) |
| | Re: powershell equivalent of "DIR \\server\path /A:D /S /B" Perhaps a better way GCI $homeroot\$user -rec | ?{$_.PSIsContainer} | ?{$_.Name -match "\.xls|\.doc"} Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject BC> Thanks! that's awesome it's exactly what i'm looking for. BC> BC> Basically, I need to recursively check some network shares, then see BC> if they contain folders with certain names (specifically, we have BC> some weird corruption issues where files turn into folders, so i BC> need to check if each of these containers have specific file BC> extentions). I was using 'test-path', but was using a wildcard and BC> therefore it's checking EVERY folder and taking a long time. I BC> think getting a folder listing then checking the output of the GCI BC> would make it run much faster. Basically what i need to do is: BC> BC> $count = 0 BC> foreach ($user in $list) { BC> $gci = GCI $homeroot\$user -rec | ?{$_.PSIsContainer} | select BC> FullName BC> #not real code below ![]() BC> if ($gci contains ".xls" or ".doc") { BC> #resume real code BC> add-content $output $user BC> $count = $count + 1 BC> } BC> } BC> care to enlighten me on exactly how i could write that 'if' BC> statement? ![]() BC> BC> "Brandon Shell [MVP]" wrote: BC> Quote: Quote: >> Its long, but powerful. >> >> ls \\server\path -rec | ?{$_.PSIsContainer} | select FullName >> >> May I ask what you want this info for? Perhaps I can help with the >> end goal if this is not it. >> >> Brandon Shell >> --------------- >> Blog: http://www.bsonposh.com/ >> PSH Scripts Project: www.codeplex.com/psobject >> BC> How can I do something like this within powershell. >> BC> this is basically a directory listing showing only directories >> and >> BC> is >> BC> recursive. the /B makes it show only the direcotry paths, not any >> of >> BC> the >> BC> other directory information. >> BC> Thanks! >> BC> |
My System Specs![]() |
| | #6 (permalink) |
| | Re: powershell equivalent of "DIR \\server\path /A:D /S /B" 1st - Thanks for all your fast responses! it sort of works, but i think now there's something else wrong with my script, as it's only getting a match on the first user of my 'test' environment, when it should be finding stuff for other 'users' too...here's the relevant portion of my code... the deal with the $initial is that it's part of our folder structure - $home\$initial\$user foreach ($initial in $initials) { $output = "$workingdir\corrupt_users_$initial.csv" if (test-path $output) { remove-item $output } add-content $output "Name, Number of corrupt files" $csv = import-csv $workingdir\recent_users\$initial.csv $namelist = $csv | foreach-object {$_.name} foreach ($name in $namelist) { write-host "scanning $homedir\$initial\$name\" $currenttime = get-date -displayhint time write-host $currenttime # ============================ scanning for folders with file extentions ==================================== $usercorrupt = get-Childitem $homedir\$initial\$name -rec | ?{$_.PSIsContainer} | ?{$_.name -match "\.xls|\.doc|\.ppt|\.pdf"} $usercorruptcount = $usercorrupt.count if ($usercorruptcount -gt 0) { add-content $output "$name, $usercorruptcount" $totalcount = $totalcount + $usercorruptcount write-host "$name is corrupt" } "Brandon Shell [MVP]" wrote: Quote: > Perhaps a better way > > GCI $homeroot\$user -rec | ?{$_.PSIsContainer} | ?{$_.Name -match "\.xls|\.doc"} > > > Brandon Shell > --------------- > Blog: http://www.bsonposh.com/ > PSH Scripts Project: www.codeplex.com/psobject > > BC> Thanks! that's awesome it's exactly what i'm looking for. > BC> > BC> Basically, I need to recursively check some network shares, then see > BC> if they contain folders with certain names (specifically, we have > BC> some weird corruption issues where files turn into folders, so i > BC> need to check if each of these containers have specific file > BC> extentions). I was using 'test-path', but was using a wildcard and > BC> therefore it's checking EVERY folder and taking a long time. I > BC> think getting a folder listing then checking the output of the GCI > BC> would make it run much faster. Basically what i need to do is: > BC> > BC> $count = 0 > BC> foreach ($user in $list) { > BC> $gci = GCI $homeroot\$user -rec | ?{$_.PSIsContainer} | select > BC> FullName > BC> #not real code below ![]() > BC> if ($gci contains ".xls" or ".doc") { > BC> #resume real code > BC> add-content $output $user > BC> $count = $count + 1 > BC> } > BC> } > BC> care to enlighten me on exactly how i could write that 'if' > BC> statement? ![]() > BC> > BC> "Brandon Shell [MVP]" wrote: > BC> Quote: Quote: > >> Its long, but powerful. > >> > >> ls \\server\path -rec | ?{$_.PSIsContainer} | select FullName > >> > >> May I ask what you want this info for? Perhaps I can help with the > >> end goal if this is not it. > >> > >> Brandon Shell > >> --------------- > >> Blog: http://www.bsonposh.com/ > >> PSH Scripts Project: www.codeplex.com/psobject > >> BC> How can I do something like this within powershell. > >> BC> this is basically a directory listing showing only directories > >> and > >> BC> is > >> BC> recursive. the /B makes it show only the direcotry paths, not any > >> of > >> BC> the > >> BC> other directory information. > >> BC> Thanks! > >> BC> > > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: powershell equivalent of "DIR \\server\path /A:D /S /B" OK...so I figured out the problem... for my 'test' infrastructure, only one of the 'test' users has more than 1 match for the $usercorrupt = get-Childitem $homedir\$initial\$name -rec | ?{$_.PSIsContainer} | ?{$_.name -match "\.xls|\.doc|\.ppt|\.pdf"} when the $usercorrupt only has 1 match, for some reason powershell does not give any output for $usercorrupt.count (which theoretically should return a '1' if there's 1 match) as a matter of fact, when i type $usercorrupt. and hit tab, count is no longer one of the options when the count is 1. I don't think i'll run into this issue when running the script in production, because anyone impacted will have many more than 1 corrupt file...but i'd still like to know how to fix it ![]() Thanks! "Ben Christian" wrote: Quote: > 1st - Thanks for all your fast responses! > > it sort of works, but i think now there's something else wrong with my > script, as it's only getting a match on the first user of my 'test' > environment, when it should be finding stuff for other 'users' too...here's > the relevant portion of my code... > > the deal with the $initial is that it's part of our folder structure - > $home\$initial\$user > > foreach ($initial in $initials) { > $output = "$workingdir\corrupt_users_$initial.csv" > if (test-path $output) { remove-item $output } > add-content $output "Name, Number of corrupt files" > $csv = import-csv $workingdir\recent_users\$initial.csv > $namelist = $csv | foreach-object {$_.name} > foreach ($name in $namelist) { > write-host "scanning $homedir\$initial\$name\" > $currenttime = get-date -displayhint time > write-host $currenttime > > # ============================ scanning for folders with file > extentions ==================================== > $usercorrupt = get-Childitem $homedir\$initial\$name -rec | > ?{$_.PSIsContainer} | ?{$_.name -match "\.xls|\.doc|\.ppt|\.pdf"} > $usercorruptcount = $usercorrupt.count > if ($usercorruptcount -gt 0) { > add-content $output "$name, $usercorruptcount" > $totalcount = $totalcount + $usercorruptcount > write-host "$name is corrupt" > > } > > "Brandon Shell [MVP]" wrote: > Quote: > > Perhaps a better way > > > > GCI $homeroot\$user -rec | ?{$_.PSIsContainer} | ?{$_.Name -match "\.xls|\.doc"} > > > > > > Brandon Shell > > --------------- > > Blog: http://www.bsonposh.com/ > > PSH Scripts Project: www.codeplex.com/psobject > > > > BC> Thanks! that's awesome it's exactly what i'm looking for. > > BC> > > BC> Basically, I need to recursively check some network shares, then see > > BC> if they contain folders with certain names (specifically, we have > > BC> some weird corruption issues where files turn into folders, so i > > BC> need to check if each of these containers have specific file > > BC> extentions). I was using 'test-path', but was using a wildcard and > > BC> therefore it's checking EVERY folder and taking a long time. I > > BC> think getting a folder listing then checking the output of the GCI > > BC> would make it run much faster. Basically what i need to do is: > > BC> > > BC> $count = 0 > > BC> foreach ($user in $list) { > > BC> $gci = GCI $homeroot\$user -rec | ?{$_.PSIsContainer} | select > > BC> FullName > > BC> #not real code below ![]() > > BC> if ($gci contains ".xls" or ".doc") { > > BC> #resume real code > > BC> add-content $output $user > > BC> $count = $count + 1 > > BC> } > > BC> } > > BC> care to enlighten me on exactly how i could write that 'if' > > BC> statement? ![]() > > BC> > > BC> "Brandon Shell [MVP]" wrote: > > BC> Quote: > > >> Its long, but powerful. > > >> > > >> ls \\server\path -rec | ?{$_.PSIsContainer} | select FullName > > >> > > >> May I ask what you want this info for? Perhaps I can help with the > > >> end goal if this is not it. > > >> > > >> Brandon Shell > > >> --------------- > > >> Blog: http://www.bsonposh.com/ > > >> PSH Scripts Project: www.codeplex.com/psobject > > >> BC> How can I do something like this within powershell. > > >> BC> this is basically a directory listing showing only directories > > >> and > > >> BC> is > > >> BC> recursive. the /B makes it show only the direcotry paths, not any > > >> of > > >> BC> the > > >> BC> other directory information. > > >> BC> Thanks! > > >> BC> > > > > |
My System Specs![]() |
| | #8 (permalink) |
| | Re: powershell equivalent of "DIR \\server\path /A:D /S /B" Try casting $usercorrupt the value as an array. $usercorrupt = @(get-Childitem $homedir\$initial\$name -rec | ?{$_.PSIsContainer} | ?{$_.name -match \.xls|\.doc|\.ppt|\.pdf"}) The problem is that when you only get one back it treats as a System.IO.DirectoryInfo which does not have a count or length property. If you have more than one then you get an array of System.IO.DirectoryInfo which does have a count or length. By casting to an array you will always have a count. "Ben Christian" <BenChristian@xxxxxx> wrote in message news:C92AA26B-B050-421D-90B0-A645DFB1BF74@xxxxxx Quote: > OK...so I figured out the problem... > > for my 'test' infrastructure, only one of the 'test' users has more than 1 > match for the $usercorrupt = get-Childitem $homedir\$initial\$name -rec | > ?{$_.PSIsContainer} | ?{$_.name -match "\.xls|\.doc|\.ppt|\.pdf"} > > when the $usercorrupt only has 1 match, for some reason powershell does > not > give any output for $usercorrupt.count (which theoretically should return > a > '1' if there's 1 match) > as a matter of fact, when i type $usercorrupt. and hit tab, count is no > longer one of the options when the count is 1. I don't think i'll run > into > this issue when running the script in production, because anyone impacted > will have many more than 1 corrupt file...but i'd still like to know how > to > fix it ![]() > > Thanks! > > "Ben Christian" wrote: > Quote: >> 1st - Thanks for all your fast responses! >> >> it sort of works, but i think now there's something else wrong with my >> script, as it's only getting a match on the first user of my 'test' >> environment, when it should be finding stuff for other 'users' >> too...here's >> the relevant portion of my code... >> >> the deal with the $initial is that it's part of our folder structure - >> $home\$initial\$user >> >> foreach ($initial in $initials) { >> $output = "$workingdir\corrupt_users_$initial.csv" >> if (test-path $output) { remove-item $output } >> add-content $output "Name, Number of corrupt files" >> $csv = import-csv $workingdir\recent_users\$initial.csv >> $namelist = $csv | foreach-object {$_.name} >> foreach ($name in $namelist) { >> write-host "scanning $homedir\$initial\$name\" >> $currenttime = get-date -displayhint time >> write-host $currenttime >> >> # ============================ scanning for folders with file >> extentions ==================================== >> $usercorrupt = get-Childitem $homedir\$initial\$name -rec | >> ?{$_.PSIsContainer} | ?{$_.name -match "\.xls|\.doc|\.ppt|\.pdf"} >> $usercorruptcount = $usercorrupt.count >> if ($usercorruptcount -gt 0) { >> add-content $output "$name, $usercorruptcount" >> $totalcount = $totalcount + $usercorruptcount >> write-host "$name is corrupt" >> >> } >> >> "Brandon Shell [MVP]" wrote: >> Quote: >> > Perhaps a better way >> > >> > GCI $homeroot\$user -rec | ?{$_.PSIsContainer} | ?{$_.Name -match >> > "\.xls|\.doc"} >> > >> > >> > Brandon Shell >> > --------------- >> > Blog: http://www.bsonposh.com/ >> > PSH Scripts Project: www.codeplex.com/psobject >> > >> > BC> Thanks! that's awesome it's exactly what i'm looking for. >> > BC> >> > BC> Basically, I need to recursively check some network shares, then >> > see >> > BC> if they contain folders with certain names (specifically, we have >> > BC> some weird corruption issues where files turn into folders, so i >> > BC> need to check if each of these containers have specific file >> > BC> extentions). I was using 'test-path', but was using a wildcard and >> > BC> therefore it's checking EVERY folder and taking a long time. I >> > BC> think getting a folder listing then checking the output of the GCI >> > BC> would make it run much faster. Basically what i need to do is: >> > BC> >> > BC> $count = 0 >> > BC> foreach ($user in $list) { >> > BC> $gci = GCI $homeroot\$user -rec | ?{$_.PSIsContainer} | select >> > BC> FullName >> > BC> #not real code below ![]() >> > BC> if ($gci contains ".xls" or ".doc") { >> > BC> #resume real code >> > BC> add-content $output $user >> > BC> $count = $count + 1 >> > BC> } >> > BC> } >> > BC> care to enlighten me on exactly how i could write that 'if' >> > BC> statement? ![]() >> > BC> >> > BC> "Brandon Shell [MVP]" wrote: >> > BC> >> > >> Its long, but powerful. >> > >> >> > >> ls \\server\path -rec | ?{$_.PSIsContainer} | select FullName >> > >> >> > >> May I ask what you want this info for? Perhaps I can help with the >> > >> end goal if this is not it. >> > >> >> > >> Brandon Shell >> > >> --------------- >> > >> Blog: http://www.bsonposh.com/ >> > >> PSH Scripts Project: www.codeplex.com/psobject >> > >> BC> How can I do something like this within powershell. >> > >> BC> this is basically a directory listing showing only directories >> > >> and >> > >> BC> is >> > >> BC> recursive. the /B makes it show only the direcotry paths, not >> > >> any >> > >> of >> > >> BC> the >> > >> BC> other directory information. >> > >> BC> Thanks! >> > >> BC> >> > >> > >> > |
My System Specs![]() |
| | #9 (permalink) |
| | Re: powershell equivalent of "DIR \\server\path /A:D /S /B" Awesome! Thank you thank you thank you ![]() "Brandon Shell [MVP]" wrote: Quote: > Try casting $usercorrupt the value as an array. > $usercorrupt = @(get-Childitem $homedir\$initial\$name -rec | > ?{$_.PSIsContainer} | ?{$_.name -match \.xls|\.doc|\.ppt|\.pdf"}) > > The problem is that when you only get one back it treats as a > System.IO.DirectoryInfo which does not have a count or length property. If > you have more than one then you get an array of System.IO.DirectoryInfo > which does have a count or length. By casting to an array you will always > have a count. > > > "Ben Christian" <BenChristian@xxxxxx> wrote in message > news:C92AA26B-B050-421D-90B0-A645DFB1BF74@xxxxxx Quote: > > OK...so I figured out the problem... > > > > for my 'test' infrastructure, only one of the 'test' users has more than 1 > > match for the $usercorrupt = get-Childitem $homedir\$initial\$name -rec | > > ?{$_.PSIsContainer} | ?{$_.name -match "\.xls|\.doc|\.ppt|\.pdf"} > > > > when the $usercorrupt only has 1 match, for some reason powershell does > > not > > give any output for $usercorrupt.count (which theoretically should return > > a > > '1' if there's 1 match) > > as a matter of fact, when i type $usercorrupt. and hit tab, count is no > > longer one of the options when the count is 1. I don't think i'll run > > into > > this issue when running the script in production, because anyone impacted > > will have many more than 1 corrupt file...but i'd still like to know how > > to > > fix it ![]() > > > > Thanks! > > > > "Ben Christian" wrote: > > Quote: > >> 1st - Thanks for all your fast responses! > >> > >> it sort of works, but i think now there's something else wrong with my > >> script, as it's only getting a match on the first user of my 'test' > >> environment, when it should be finding stuff for other 'users' > >> too...here's > >> the relevant portion of my code... > >> > >> the deal with the $initial is that it's part of our folder structure - > >> $home\$initial\$user > >> > >> foreach ($initial in $initials) { > >> $output = "$workingdir\corrupt_users_$initial.csv" > >> if (test-path $output) { remove-item $output } > >> add-content $output "Name, Number of corrupt files" > >> $csv = import-csv $workingdir\recent_users\$initial.csv > >> $namelist = $csv | foreach-object {$_.name} > >> foreach ($name in $namelist) { > >> write-host "scanning $homedir\$initial\$name\" > >> $currenttime = get-date -displayhint time > >> write-host $currenttime > >> > >> # ============================ scanning for folders with file > >> extentions ==================================== > >> $usercorrupt = get-Childitem $homedir\$initial\$name -rec | > >> ?{$_.PSIsContainer} | ?{$_.name -match "\.xls|\.doc|\.ppt|\.pdf"} > >> $usercorruptcount = $usercorrupt.count > >> if ($usercorruptcount -gt 0) { > >> add-content $output "$name, $usercorruptcount" > >> $totalcount = $totalcount + $usercorruptcount > >> write-host "$name is corrupt" > >> > >> } > >> > >> "Brandon Shell [MVP]" wrote: > >> > >> > Perhaps a better way > >> > > >> > GCI $homeroot\$user -rec | ?{$_.PSIsContainer} | ?{$_.Name -match > >> > "\.xls|\.doc"} > >> > > >> > > >> > Brandon Shell > >> > --------------- > >> > Blog: http://www.bsonposh.com/ > >> > PSH Scripts Project: www.codeplex.com/psobject > >> > > >> > BC> Thanks! that's awesome it's exactly what i'm looking for. > >> > BC> > >> > BC> Basically, I need to recursively check some network shares, then > >> > see > >> > BC> if they contain folders with certain names (specifically, we have > >> > BC> some weird corruption issues where files turn into folders, so i > >> > BC> need to check if each of these containers have specific file > >> > BC> extentions). I was using 'test-path', but was using a wildcard and > >> > BC> therefore it's checking EVERY folder and taking a long time. I > >> > BC> think getting a folder listing then checking the output of the GCI > >> > BC> would make it run much faster. Basically what i need to do is: > >> > BC> > >> > BC> $count = 0 > >> > BC> foreach ($user in $list) { > >> > BC> $gci = GCI $homeroot\$user -rec | ?{$_.PSIsContainer} | select > >> > BC> FullName > >> > BC> #not real code below ![]() > >> > BC> if ($gci contains ".xls" or ".doc") { > >> > BC> #resume real code > >> > BC> add-content $output $user > >> > BC> $count = $count + 1 > >> > BC> } > >> > BC> } > >> > BC> care to enlighten me on exactly how i could write that 'if' > >> > BC> statement? ![]() > >> > BC> > >> > BC> "Brandon Shell [MVP]" wrote: > >> > BC> > >> > >> Its long, but powerful. > >> > >> > >> > >> ls \\server\path -rec | ?{$_.PSIsContainer} | select FullName > >> > >> > >> > >> May I ask what you want this info for? Perhaps I can help with the > >> > >> end goal if this is not it. > >> > >> > >> > >> Brandon Shell > >> > >> --------------- > >> > >> Blog: http://www.bsonposh.com/ > >> > >> PSH Scripts Project: www.codeplex.com/psobject > >> > >> BC> How can I do something like this within powershell. > >> > >> BC> this is basically a directory listing showing only directories > >> > >> and > >> > >> BC> is > >> > >> BC> recursive. the /B makes it show only the direcotry paths, not > >> > >> any > >> > >> of > >> > >> BC> the > >> > >> BC> other directory information. > >> > >> BC> Thanks! > >> > >> BC> > >> > > >> > > >> > |
My System Specs![]() |
| | #10 (permalink) |
| | Re: powershell equivalent of "DIR \\server\path /A:D /S /B" To ensure a count of items when the amount of items returned is uknown is best to enclose the statement in an array subexpression @(). [IO.DirectoryInfo] has an Extension property. PowerShell allows more than one condition in a conditional statement. # try this: $usercorrupt = @(get-Childitem $homedir\$initial\$name -rec | ? {$_.PSIsContainer -and $_.extension -match "xls|doc|ppt|pdf"}) $usercorruptcount = $usercorrupt.count if ($usercorruptcount) { add-content $output "$name, $usercorruptcount" $totalcount += $usercorruptcount write-host "$name is corrupt" } # or, if $usercorrupt is mot used furher, try this: $usercorruptcount = @(get-Childitem $homedir\$initial\$name -rec | ? {$_.PSIsContainer -and $_.extension -match "xls|doc|ppt|pdf"}).count if ($usercorruptcount) { add-content $output "$name, $usercorruptcount" $totalcount += $usercorruptcount write-host "$name is corrupt" } -- Kiron |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Re: "Virtual Server 2005 R2 SP1" on "Windows Web Server 2008" host? | Virtual Server | |||
| is there an equivalent Function to FORMAT(56,"0000") | VB Script | |||
| Powershell "Net User" equivalent | PowerShell | |||
| "Open command prompt here" and "Copy as path" | Vista performance & maintenance | |||
| Is there an equivalent of the DOS shell "start /wait" in PowerShel | PowerShell | |||