Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepowershell
Write-Output "Starting to gather member list for $GroupName"
Get-MsolGroupMember -GroupObjectId $GroupId -MaxResults 1000000 |
    Where-Object { $_.GroupMemberType -eq "User" } | 
    Foreach { Get-MsolUser -UserPrincipalName $_.EmailAddress | Select DisplayName, UserPrincipalName, UserType, UsageLocation, Country, State, City, Department, IsLicensed } |
    Export-Csv -Path $filePath -NoTypeInformation -Encoding UTF8

Write-Output "All members found and exported to the CSV."
Write-Output $(FormatForDownloadLink $filePath)

For a more advanced use case, see Creating custom connections scripts, such as to the Microsoft Graph API