Tuesday, April 3, 2012

Get SiteUsers and SiteGroups in PowerShell

Leave a Comment
To create this script, open notepad or any other text editor and save it as .ps1


Script to get SiteUsers. 

$site = Get-SPSite("site url");
$web = $site.OpenWeb();
$users = $web.SiteUsers;

$users | ForEach-Object{ Write-Host $_.Name -Foregroundcolor red};

After saving this file, open powershell and run this ps1 file.


Script to get SiteGroups


$site = Get-SPSite("site url");

$web = $site.OpenWeb();
$groups = $web.SiteGroups

$groups | ForEach-Object{ Write-Host $_.Name -Foregroundcolor red};




0 comments: