Link to home
Start Free TrialLog in
Avatar of hafka
hafka

asked on

Query shared folder and the size

How could I query shared folders from windows machine with size, excluding shares with $-in the share name?

Input should be servers.txt where the machine names are listed one per row.
Output should be result.txt:
\\MachineName\ShareName, local path, size
\\MachineName\ShareName, local path, size
\\MachineName\ShareName, local path, size

I can query shares from a specific computer with this:
Get-WmiObject win32_share -computerName InsertComputerNameHere  | Where {$_.name -notlike "*$"} | sort-Object -property path | ft path, name -autosize

I can query a specific folder size with this:
$colItems = (Get-ChildItem C:\temp -recurse | Measure-Object -property length -sum)
"{0:N2}" -f ($colItems.sum / 1MB) + " MB "

But I do not know how to put all this together.
SOLUTION
Avatar of soostibi
soostibi
Flag of Hungary image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial