Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save paulvill76/ed1a5b6352f06eadab6d15d48f7c4ba2 to your computer and use it in GitHub Desktop.
Save paulvill76/ed1a5b6352f06eadab6d15d48f7c4ba2 to your computer and use it in GitHub Desktop.
Adding AAD members to an AAD group based on CSV file
# Read in a list of user accounts from a CSV
#
# -- Begin sample CSV file --
# Username
# dtrump
# bobama
# gbush
# -- End sample CSV file --
#
$GroupObjectID = (Get-AzureADGroup -SearchString "your_groupname_here").ObjectID
$CSV = import-csv "c:\temp\your_csv_file_here.csv"
$CSV.Name | foreach-object {
$User = Get-AzureADUser -SearchString $_
$UserObjectID = $User.ObjectID
Add-AzureADGroupMember -ObjectID $GroupObjectID -RefObjectID $UserObjectID
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment