We have recently been looking to audit some Windows servers shares and permissions. I have previously used a script to export folder permissions, so some of this script will be from that previous script. The main difference is that we will be using WMI query to get the list of shares and a looping through specified servers.
To get the list of shares we will use the Win32_Share WMI class and filtered out the default shares.
Get-WmiObject -ComputerName $Server -Class win32_share -Filter "Description != 'Remote Admin' and Description != 'Default share' and Description != 'Remote IPC' and Description != 'Printer Drivers'" | Select-Object Name -ExpandProperty Name
The full script that will be used is located on my Github repository, see link below.
To run the script use the below and update the exportpath and servers. To add multiple server just a comma between server names.
.\Get-SharesAndPermissions.ps1 -ExportPath D:\Scripts\Folder_Permissions\Export -Servers Server1, Server2
Once the script has completed the result will be export to a csv in the exported folder path.