if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) {
Add-PSSnapin Microsoft.SharePoint.Powershell
}
$SiteCollURL = read-host "Enter the site colelction URL "
$siteColl = get-spsite $SiteCollURL
foreach($web in $sitecoll.allwebs)
{
write-host "Users under the web "$web.url -fore cyan
foreach($user in $web.siteusers)
{
write-host "User: " $User.loginname -fore green
}
}
write-host ""
write-host "SCRIPT COMPLETED" -fore greenIn this code snippet you will learn how to list all the users under particular site collection in SharePoint.
