[英]Getting "An item with the same key has already been added" Error when I try to create a new client secret via AzAD module
I'm quite puzzled.我很困惑。 I'm trying to use powershell to create a new client secret for an Azure application.
我正在尝试使用 powershell 为 Azure 应用程序创建新的客户端密码。 I'm hitting the error "An item with the same key has already been added" but there's currently no client secret assigned to the application.
我遇到错误“已添加具有相同密钥的项目”,但目前没有为应用程序分配客户端密码。 Any ideas would be great.
任何想法都会很棒。
Connect-AzAccount
$sp = Get-AzADServicePrincipal -DisplayName "TS-Test-14-Oct-2021"
$start = Get-Date -Format "o"
$end = (Get-Date).AddYears(1) | Get-Date -Format "o"
$Guid = (New-guid).toString()
$Password = @{
displayName= 'Hi'
endDateTime= $end
hint= 'NIL'
keyId= "$Guid"
secretText= 'xxxx'
startDateTime= $start
}
New-AzADAppCredential -ObjectId $sp.Id -PasswordCredentials $Password
I tried with your code and facing the same issue我尝试使用您的代码并面临同样的问题
You can try with this code:您可以尝试使用以下代码:
$startDate = Get-Date
$endDate = $startDate.AddYears(3)
$aadAppsecret01 = New-AzureADApplicationPasswordCredential -ObjectId ObjectId CustomKeyIdentifier "Secret01" -StartDate $startDate -EndDate $endDate
OUTPUT OUTPUT
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.