Last active
April 4, 2022 18:22
-
-
Save jammykam/74412aa261be522c5d2027f53b625f6d to your computer and use it in GitHub Desktop.
Create Users and Add to specified roles from CSV file using Sitecore PowerShell Extensions
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
$VerbosePreference = "Continue" | |
$newUsersFile = Receive-File -Path "C:\temp\upload" -CancelButtonName "No, I will do it using MS Excel instead" | |
$newUsers = Import-Csv -Path $newUsersFile | |
foreach($user in $newUsers) { | |
Write-Verbose "Creating User: $($user.Username)" | |
New-User -Identity $($user.Username) -Enabled -Password $($user.Password) -Email $($user.Email) -FullName "$($user.Name)" | |
$($user.Roles).Split(",") | ForEach { | |
Write-Verbose "Adding user to role: $_ " | |
Add-RoleMember -Identity $_ -Members "$($user.Username)" | |
} | |
} |
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
Name | Username | Password | Roles | ||
---|---|---|---|---|---|
Jammy KamSir | jammykam | real | [email protected] | Author,Developer | |
Fake Kam | kamsar | fake | [email protected] | Developer,Experience Explorer | |
Real Unicorn Guy | unicornguy | B4D455 | [email protected] | Sitecore Local Administrators |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment