When getting a list of shares, PowerShell responds with, “Cannot validate argument on parameter ‘Path’. The argument is null or empty…”; happens on any system after the last drive share is listed (C$, D$, E$, etc.), while anything else is listed just fine.
$PSShareObject = Get-WmiObject -Class Win32_Share -Namespace 'root\CIMv2' foreach($share in $PSShareObject) { $ShareName = ($share).Name $SharePath = ($share).Path $ShareDescription = ($share).Description $NTFSPermissions = (Get-Acl -Path $SharePath).AccessToString $Asset = New-Object -TypeName PSObject $Dictionary = [ordered]@{ "Path" = (Pad-Object $SharePath); "Description" = (Pad-Object $ShareDescription); "NTFS Permissions" = (Pad-Object $NTFSPermissions) } }
(Some code truncated to save time.)
Perhaps there is a more efficient way to do this… Would appreciate some input.
Thank you.