01.
if
((Get-PSSnapin
"Microsoft.SharePoint.PowerShell"
-ErrorAction SilentlyContinue) -eq $
null
)
02.
{
03.
Add-PSSnapin
04.
}
05.
$SPFile =
".\GetGroupInformation.txt"
06.
$SPSiteUrl = Read-Host
"Enter the Url of the Site Collection "
07.
$SPSite = Get-SPSite $SPSiteUrl -ErrorAction SilentlyContinue
08.
09.
($SPSite -ne $
){
10.
$SPWebCollection = $SPSite.AllWebs
11.
foreach
($SPWeb
in
$SPWebCollection){
12.
Write-Output $SPWeb.Title
"contains the following groups"
| Out-File $SPFile -append
13.
Write-Output
"========================"
14.
($SPGroup
$SPWeb.Groups){
15.
Write-Output $SPGroup.Name| Out-File $SPFile -append
16.
17.
18.
19.
20.
else
21.
22.
Write-Host
"Requested Site Could Not be found"
-ForegroundColor DarkRed
23.