I am using DU.exe in Powershell script to capture the size of a remote folder, code as 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 to redirect the stderror to stop an error caused by the "-q" switch. However the 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 is this? If I run du outside powershell I get no errors on the same unc paths.