Created
February 3, 2016 20:48
-
-
Save sballarati/b078e956f3c07464c001 to your computer and use it in GitHub Desktop.
Creates an Azure Active Directory Service Principal
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
#connect using a global admin account of the AD where you want the Service Principal to be created | |
$msolcred = get-credential | |
connect-msolservice -credential $msolcred | |
#symmetric key used for some auth scenarios (keep the object id, app principal id and symm key for the future) | |
New-MsolServicePrincipal -DisplayName {yourspname} -Type symmetric | |
#assigns a Company Admin role | |
Add-MsolRoleMember -RoleName "Company Administrator" -RoleMemberType ServicePrincipal -RoleMemberObjectId {principal objectId} | |
#the password credential will be valid for 1 year, you can also set another value | |
New-MsolServicePrincipalCredential -AppPrincipalId {principalId} -Type Password -StartDate ([DateTime]::Now.AddMinutes(-5)) -EndDate ([DateTime]::Now.AddMonths(12)) -Value "{yourpass}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment