Skip to content

Instantly share code, notes, and snippets.

@weeyin83
Created January 3, 2020 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weeyin83/52c91d2394a67c813927582b102b895d to your computer and use it in GitHub Desktop.
Save weeyin83/52c91d2394a67c813927582b102b895d to your computer and use it in GitHub Desktop.
Create an Azure Service Principal in PowerShell
# Create the Service Principal, generates a random password
$sp = New-AzADServicePrincipal -DisplayName ServicePrincipalName
# Export the random password that was generated on creation
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sp.Secret)
$UnsecureSecret = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
$UnsecureSecret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment