Powershell Du.exe Error -


i using du.exe in powershell script capture size of remote folder, code below:

$duexe ="c:\du\du.exe"  $unc = "\\$server\$letter$\$name"  write-host "processing:  " $unc  $stuff =  du -q "\\$server\$letter$\$name" 2>&1   $formated = $stuff | format-table -auto  write-host $stuff 

i have redirect stderror stop error caused "-q" switch. output contians following error:

system.management.automation.remoteexception  in context:  files:        290215 directories:  2246 size:         128,529,542,967 bytes size on disk: 128,529,542,967 bytes  system.management.automation.remoteexception  

why this? if run du outside powershell no errors on same unc paths.

you didn't stop error "redirect" error output stream captured in variable $stuff. try redirecting error stream $null ignore it:

$stuff =  du -q "\\$server\$letter$\$name" 2> $null  $stuff | format-table -auto 

btw, don't need write-host "formatted" stuff. format-table output host automatically.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -