$Output="D:\Output.csv"
"Username"+","+"Email" | Out-File -Encoding Default -FilePath $Output;
$Site = Get-SPSite "http://test.contoso.com"
$Context=[Microsoft.Office.Server.ServerContext]::GetContext($Site)
$AudManager=New-Object Microsoft.Office.Server.Audience.AudienceManager($Context)
$Audience=$AudManager.Audiences | Where {$_.AudienceName -eq "TestAudienceGroup"}
Foreach ($Member in $Audience.GetMembership())
{
Write-Host $Member.NTName
Write-Host $Member.Email
$Member.NTName + "," + $Member.Email | Out-File -Encoding Default -Append -FilePath $Output
}
"Username"+","+"Email" | Out-File -Encoding Default -FilePath $Output;
$Site = Get-SPSite "http://test.contoso.com"
$Context=[Microsoft.Office.Server.ServerContext]::GetContext($Site)
$AudManager=New-Object Microsoft.Office.Server.Audience.AudienceManager($Context)
$Audience=$AudManager.Audiences | Where {$_.AudienceName -eq "TestAudienceGroup"}
Foreach ($Member in $Audience.GetMembership())
{
Write-Host $Member.NTName
Write-Host $Member.Email
$Member.NTName + "," + $Member.Email | Out-File -Encoding Default -Append -FilePath $Output
}
No comments:
Post a Comment