Last active
August 19, 2020 23:30
-
-
Save jkbryan/8f41fc26ec89be1717c1b44ea7d51e1a to your computer and use it in GitHub Desktop.
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
# Login first | |
Login-AzAccount | |
# Note that you can optionally assign an Azure role on creation, | |
# define the context prior to SP creation, using Set-AzContext | |
# | |
# Create Service Principle | |
$sp = New-AzADServicePrincipal -Role Reader -DisplayName "MyServicePrinciple" | |
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sp.Secret) | |
$UnsecureSecret = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) | |
# Write out the password for the SP. Make sure you keep a secure copy of this output! | |
Write-Host $UnsecureSecret | |
# | |
# Assuming that you want to get the SP's AppID or ObjectID after creation: | |
Get-AzADServicePrincipal -DisplayNameBeginsWith "myserv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment