Skip to content

Instantly share code, notes, and snippets.

@eosfor
Last active August 9, 2018 11:49
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 eosfor/42f437d8230a7527abfdc3c0d34ee10c to your computer and use it in GitHub Desktop.
Save eosfor/42f437d8230a7527abfdc3c0d34ee10c to your computer and use it in GitHub Desktop.
When you accidentally deleted password of a security principal
$passwords = "<pwd1>",
"<pwd2>",
"<pwd3>"
$keys = $passwords | % {
$sDate = Get-Date
$eDate = $sDate.AddYears(10)
$kID = (New-Guid).Guid
$value = $_
$keydata = [Microsoft.Azure.Graph.RBAC.Version1_6.Models.PasswordCredential]::new($sDate, $eDate, $kID, $value)
$keydata
}
Update-AzureRmADServicePrincipal -ApplicationId "<some guid>" -PasswordCredential $keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment