With this powershell command you will be to Add a new user in CMS.
$firstName = Show-Input "FirstName : " -MaxLength 30
$lastName = Show-Input "LastName : " -MaxLength 30
$email = Show-Input "Email : " -MaxLength 30
$password = Show-Input "Password : " -MaxLength 30
$fullname = $firstName + " " + $lastName
$username = $firstName + "_" + $lastName
Write-Host "FirstName: " $firstName
Write-Host "lastName: "$lastName
Write-Host "fullname: "$fullname
Write-Host "email: "$email
Write-Host "username: "$username
Write-Host "password: "$password
if($fullname -ne $null -and $email -ne $null -and $username -ne $null -and $password -ne $null)
{
$newUser = New-User -Identity $username -Enabled -Password $password -Email $email -FullName $fullName
if($newUser.Domain -eq "sitecore")
{
$developer = Show-Confirm -Title "Add this user to SITECORE DEVELOPER role by pressing - OK"
if($developer -eq "yes"){
Add-RoleMember -Identity "sitecore\Developer" -Members $username
}
else
{
$contenteditor = Show-Confirm -Title "Add this user to CONTENT EDITOR or FE DEVELOPER role by pressing - OK"
if($contenteditor -eq "yes"){
Add-RoleMember -Identity "sitecore\Content Editor" -Members $username
}
else
{
$contentManager = Show-Confirm -Title "Add this user to CONTENT Manager or QA role by pressing - OK"
if($contentManager -eq "yes"){
Add-RoleMember -Identity "sitecore\Content Manager" -Members $username
}
else
{
$administrator = Show-Confirm -Title "Make this user administrator by pressing - OK"
if($administrator -eq "yes"){#set user as administrator
Set-User -Identity $username -IsAdministrator $true
}
else
{
Show-Alert -Title "User created. Username: $username. No role added to this user"
exit
}
}
}
}
Show-Alert -Title "User created. Username: $username"
}
}
else
{
Show-Alert -Title "Please fill all the fields. No user created."
}