Pregled dijeljenih mapa i prava korisnika putem PowerShell skripte

Prikupljanje dijeljenih mapa na Microsoft Windows poslužiteljima putem PS.

Function Get-NtfsRights(name,path,comp)
{
path = [regex]::Escape(path)share = "\\comp\$name"wmi = gwmi Win32_LogicalFileSecuritySetting -filter "path='path'" -ComputerNamecomp
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

 

Izvor: http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/1903cfde-ad34-464e-9419-94d07ed9de88

 

Leave a Reply