Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

script to export share folder NTFS security permission

$
0
0

Hi

I got below one script to export share folder permission. But I am not getting where can i define the share folder path in the below script.

===============Script=============

Function Get-NtfsRights($name,$path,$comp) {$path=[regex]::Escape($path)$share="\\$comp\$name"$wmi= gwmi Win32_LogicalFileSecuritySetting -filter"path='$path'"-ComputerName $comp$wmi.GetSecurityDescriptor().Descriptor.DACL | where {$_.AccessMask -as[Security.AccessControl.FileSystemRights]} |select ` @{name="Principal";Expression={"{0}\{1}"-f $_.Trustee.Domain,$_.Trustee.name}}, @{name="Rights";Expression={[Security.AccessControl.FileSystemRights]$_.AccessMask }}, @{name="AceFlags";Expression={[Security.AccessControl.AceFlags]$_.AceFlags }}, @{name="AceType";Expression={[Security.AccessControl.AceType]$_.AceType }}, @{name="ShareName";Expression={$share}} } gc serverlist.txt | foreach { if ($shares = Get-WmiObject Win32_Share -ComputerName $_ | Where {$_.Path}) { $shares | Foreach { Write-Progress -Status "Get share information on $($_.__Server)" $_.Name Get-NtfsRights $_.Name $_.Path $_.__Server} } else {"Failed to get share information from {0}." -f $($_.ToUpper())} } | ft Principal,Rights,AceFlags,AceType -GroupBy ShareName -Wrap | Out-File result.txt

===============================================================


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>