QuickTip: Using Win32_Share to only select non-default shares

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.

Share

2 thoughts on “QuickTip: Using Win32_Share to only select non-default shares

    1. Jaap Brasser Post author

      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.

      Reply

Leave a Reply

Your email address will not be published.