Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

List user shared file permission

$
0
0

Hi,

 

Using below script i am able to get the shared folder permission including  windows default share( ADMIN$, C$ etc).

Can you please help me how to exclude default share in below 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}}

}

Get-NtfsRights

 

 

gc d:\monitor\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 8583

Trending Articles