The Win32_Share class can be used to remotely or locally gather a listed of shared folders and their properties. Since every Windows system by default has a number of standard shared folder it can be interesting to only select the non-default shares. The following line of code allows you to do that:
Get-WmiObject Win32_Share | Where-Object {(@('Remote Admin','Default share','Remote IPC') -notcontains $_.Description)} |
Note that this only works for systems with English localization options. For other languages the names in the array will have to be changed to match to localized names.
Hi,
Nice tip, but I prefer the filtering based on the ‘type’ property of the Win32_Share class http://msdn.microsoft.com/en-us/library/aa394435%28v=vs.85%29.aspx
Get-WmiObject Win32_Share | Where Type -notmatch '21474836\d{2}'
Correct, another alternative would be to filter on Type -eq 0, this will also exclude Shared Printers and Devices. Or if you would like to include those device Type -lt 4 would suffice.
Thanks for sharing your solution though I didn’t think to use a regular expression for this.