- Open the Powershell ISE → Create new script with the following code and run it, specifying the path for the export:
# Import the AD module to the session
Import-Module ActiveDirectory
# Retrieve the dNSHostName attribute from all computer accounts in AD
$ComputerNames = Get-ADComputer -Filter * -Properties dNSHostName |Select-Object -ExpandProperty dNSHostName
$AllComputerShares = @()
foreach($Computer in $ComputerNames)
{
try{
$Shares = Get-WmiObject -ComputerName $Computer -Class Win32_Share -ErrorAction Stop
$AllComputerShares += $Shares
}
catch{
Write-Error "Failed to connect retrieve Shares from $Computer"
}
}
# Select the computername and the name, path and comment of the share and Export
$AllComputerShares |Select-Object -Property PSComputerName,Name,Path,Description |Export-Csv -Path C:\data\pcshares.csv -NoTypeInformation
- Open the file produced by the script in MS Excel.
Sample report:
- Run Netwrix Auditor → Navigate to Reports → Open “Windows Server” → Go to “Windows Server - State-in-Time” → Select “File Shares on Windows Servers” → Click “View”.
- To save the report, click the “Export” button and choose PDF, Word or Excel format. To receive the report regularly by email, click the “Subscribe” button and choose the schedule you prefer.
Sample report: