Condividi tramite


SharePoint 2010: elencare gli utenti di un sito che hanno i permessi Full Control/Owners con uno script Powershell Script (it-IT)

SharePoint 2010

Il seguente script PowerShell può essere usato per elencare gli utenti che hanno il permesso Full Control nei siti.

$Output =@();

$Path = "";

#Using pipe separator since we have "," separating the Last Name and First Name

$Output += ("SiteCollectionID|WebSiteUrl|Scope|User|Email");

$WebUrl ="";

[System.Reflection.Assembly]::LoadWithPartialName("System");

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint");

#Web Application URL

$WebApplicationURL = "http://<WebAppUrl>";

#Enumerate through all Site Collections and Sites

Get-SPWebApplication -Identity $WebApplicationURL | Get-SPSite -limit all | Get-SPWeb -limit all|%{

$web = $_;

#Check if the site has unique permissions

if($web.HasUniqueRoleAssignments -eq "True" -and $web.IsRootWeb -eq "False"){

$WebUrl = $web.Url;

try{

#Enumerate through all Users in the Web

foreach($user in $web.Users){

$UserName = $user.Name;

#Check if user has Full Control Permissions

if($web.DoesUserHavePermissions($user,[Microsoft.SharePoint.SPBasePermissions]::FullMask)){

$Output += ($web.Site.ID.ToString() +"|"+$web.URL + "|Site|"  +$user.Name + "|" +$user.Email);

}

}

#Get Groups containing Owners in the Title and check for Full Mask Permissions

$OwnerGroups = $web.Groups| where {$_.Name -match “Owners” }

foreach($group in $OwnerGroups){

#$IsFullControlOwnerGroup = $group.Roles|where {$_.PermissionMask -eq "FullMask"}

#if($IsFullControlOwnerGroup.Count -gt "0"){

foreach($user in $group.Users){

$Output += ($web.Site.ID.ToString()+"|"+$web.URL + "|" + $group.Name + "|" + $user.Name + "|" + $user.Email);}

#}

}

$IsFullControlOwnerGroup =$null;

$web.Dispose();

}

catch [System.Exception]{

Write-Host ($WebUrl + ":" + $_.Exception.Message + ":" + $_.Exception.StackTrace);

}

}

}

$Output > ($Path + "\SiteOwners.csv")


Altre lingue

Questo articolo è disponibile anche nelle seguenti lingue:

English (en-US)