Clear-Host
if((Get-PSSnapin | where{$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
{
Add-PSSnapin Microsoft.SharePoint.PowerShell;
Write-Host "Snap In Added";
}
$SiteUrl = "<site url>/sites/ags/spg/pit/pitsite";
Function GetFiles($folder)
{
# Use recursion to loop through all subfolders.
foreach ($spFolder in $folder.SubFolders)
{
if($spFolder.Name -ne 'Forms')
{
if($spFolder.Item.HasUniqueRoleAssignments)
{
$roleAssignments = $spFolder.Item.RoleAssignments;
if ($roleAssignments.Count -gt 0) {
foreach ($role in $roleAssignments){
$eachRole = $role.Member.ToString();
$allRoles += $eachRole + ";";
}
$url=$SiteUrl+"/"+$spFolder.Url
#$link = "<a href=" + $url + ">" +$url + "</a>";
$OutInfo = $spFolder.Name + "," + $url + "," + "No" + "," + $allRoles;
Add-Content -Value $OutInfo -Path $OutFile
}
}
else
{
$url=$SiteUrl+"/"+$spFolder.Url
$OutInfo = $spFolder.Name + "," + $url + "," + "Yes" + "," + "";
Add-Content -Value $OutInfo -Path $OutFile
}
}
GetFiles($spFolder)
}
}
$OutFile = "D:\test\Permissions.csv"
$Header = "Folder Name,Folder URL,IsInherited,Permissions"
Del $OutFile
Add-Content -Value $Header -Path $OutFile
$web = Get-SPWeb -Identity "<site url>sites/ags/spg/pit/pitsite"
$list = $web.GetList("<siteurl>/sites/ags/spg/pit/pitsite/Shared Documents")
GetFiles($list.RootFolder)
nice, but, need items too, not only folders, can you give me a hint to get that?
ReplyDelete