Last active
May 8, 2019 15:42
-
-
Save msidmvp/7156615d507d49e8c0bafc3c72a50666 to your computer and use it in GitHub Desktop.
Adding AAD members to an AAD group based on CSV file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
Hi, Trying to use this to add Guest account does like username any suggestion