$SPWebCollection = $SPSite.AllWebs
$rootSite = $SPSite.RootWeb
foreach($SPGroup in $rootSite.Groups)
{
foreach($user in $SPGroup.users)
{
$users = new-object psobject
$users | add-member noteproperty -name "Group Name" -value $SPGroup.Name
$users | add-member noteproperty -name "User" -value $user
$users | add-member noteproperty -name "Display Name" -value $user.DisplayName
$email = GetInfo $user
$users | add-member noteproperty -name "Work Email" -value $email
$combinedusers =[Array]$combinedusers + $users
}
}
#Create CSV file
$filelocation=$filePath+"\"+$rootSite+".csv"
$combinedUsers | export-csv -path $filelocation -notype
$combinedUsers = $null
$rootSite = $SPSite.RootWeb
foreach($SPGroup in $rootSite.Groups)
{
foreach($user in $SPGroup.users)
{
$users = new-object psobject
$users | add-member noteproperty -name "Group Name" -value $SPGroup.Name
$users | add-member noteproperty -name "User" -value $user
$users | add-member noteproperty -name "Display Name" -value $user.DisplayName
$email = GetInfo $user
$users | add-member noteproperty -name "Work Email" -value $email
$combinedusers =[Array]$combinedusers + $users
}
}
#Create CSV file
$filelocation=$filePath+"\"+$rootSite+".csv"
$combinedUsers | export-csv -path $filelocation -notype
$combinedUsers = $null
No comments:
Post a Comment