Skip to content

Instantly share code, notes, and snippets.

@neerajks77
Last active February 4, 2024 13:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save neerajks77/b093a5da2e05c7896e64abd2009b06a7 to your computer and use it in GitHub Desktop.
Save neerajks77/b093a5da2e05c7896e64abd2009b06a7 to your computer and use it in GitHub Desktop.
This script will create the service principal in Azure AD and will be used for Azure Automation
#This function creates an Azure AD Service Principal
function CreateServicePrincipal {
param($username, $password)
$credproperties = @{
StartDate = Get-Date
EndDate = Get-Date -Year 2024
Password = $password
}
$cred= New-Object Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential -Property $credproperties
$sp = New-AzAdServicePrincipal -DisplayName $username -PasswordCredential $cred
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment