Skip to content

Instantly share code, notes, and snippets.

@dollarpo7
Created June 24, 2020 08:19
Show Gist options
  • Select an option

  • Save dollarpo7/364bb7796587c5356aaa4de7646f3bff to your computer and use it in GitHub Desktop.

Select an option

Save dollarpo7/364bb7796587c5356aaa4de7646f3bff to your computer and use it in GitHub Desktop.
PS Function that creates an Azure Service Principal
function New-Sp {
param($Name, $Password)
$spParams = @{
StartDate = Get-Date
EndDate = Get-Date -Year 2030
Password = $Password
}
$cred= New-Object Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential -Property $spParams
$sp = New-AzAdServicePrincipal -DisplayName $Name -PasswordCredential $cred
Write-Output $sp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment