Forked from msidmvp/gist:7156615d507d49e8c0bafc3c72a50666
Created
May 8, 2019 15:42
-
-
Save paulvill76/ed1a5b6352f06eadab6d15d48f7c4ba2 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