The -class parameter is optional, PowerShell can infer from it’s position that Win32_Share is a class of WMI object. Note 3: gwmi is an alias, or shorthand way, of writing Get-WmiObject. $Share | ft name, description, type, path -auto $Share = gwmi -class Win32_Share | sort type, name # Version 2.2 March 2008 tested on PowerShell v 2.0 # Alternative PowerShell script to enumerate shared folders See more on creating and executing cmdlets. Then call this file from within by PowerShell using. Alternatively copy the code below into a file with a. It will list all the shares on your local machine.Ĭopy the text below and paste into your PowerShell command line. I have made this script short and sweet, just one line with two commands. Understand how to filter ‘Types’ of shares.Įxample 1a: Enumerate Shares with Win32_Share.Refresher, or reinforcement of the Get-Member technique.Learn how to interrogated the operating system with the WMIs class Win32_Share.To list existing shares on the local machine, including those built-in hidden ‘$’ shares. Example 1 Enumerate Shares with Win32_Share.Thanks to the WMI’s Win32_Share class, PowerShell can list or enumerate your existing file shares. In fact, planning shared folders is one of my first tasks for a new server. It’s hard to see how any network could operate without file shares. Scripting File Shares with Microsoft PowerShell