Powershell to pull network share and display their Size

So i have been working on a script to pull network share that are not hidden and display their size. but i am getting a error that states does not contain a method named 'op_addition'. The script should scan for all non hidden file shares and disply their size for what ever it find on the machine it is run on. Any help is greatly appreciated. Thanks. 

$startfolder = Get-WmiObject Win32_Share -Filter "not name like '%$'"  | Select path

foreach($folder in $startfolder.ToString){    

$colItems = (Get-ChildItem $folder -Recurse | Measure-Object -property length -sum)   

IF($colItems.Sum -ge 1073741824)   

{     

$folder + " --" +  " {0:n2}" -f  ($colItems.sum / 1GB) + " GigaBytes"   

ELSEIF($colItems.sum -ge 1024)   

{     

$folder + " --" +  " {0:n2}" -f  ($colItems.sum / 1MB) + " MegaBytes"   

ELSE   

{     $folder + " --" +  " {0:n2}" -f  ($colItems.sum / 1KB) + " KiloBytes"   

}   

}




  • Edited by marcb1387 14 hours 42 minutes ago Code structure
August 21st, 2015 12:26pm

Try it like this instead:


"$folder -- {0:n2} KiloBytes" -f ($colItems.Sum / 1KB)

Free Windows Admin Tool Kit Click here and download it now
August 21st, 2015 12:38pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics