Skip to content

Instantly share code, notes, and snippets.

@msidmvp
Last active May 8, 2019 15:42
Show Gist options
  • Save msidmvp/7156615d507d49e8c0bafc3c72a50666 to your computer and use it in GitHub Desktop.
Save msidmvp/7156615d507d49e8c0bafc3c72a50666 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
}
@da3bhayo
Copy link

Hi, Trying to use this to add Guest account does like username any suggestion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment