azure - New-AzureRmADSpCredential 永不过期的密码

标签 azure powershell

不确定这是否是我使用它的方式的错误或问题,但基本上我正在尝试使用 New-AzureRmADSpCredential 将未过期的密码添加到现有的 Azure 服务主体,但无论我向 -EndDate 提供什么参数它永远不会生效(始终设置为 1 年后过期)

示例步骤是:

$start = get-date
$end = $start.AddYears(99)
New-AzureRmADServicePrincipal -DisplayName SPTestnonExpirePW
$sp = Get-AzureRmADServicePrincipal -DisplayName "SPTestnonExpirePW"
New-AzureRmADSpCredential -ObjectId $sp.id -StartDate $start -EndDate $end -Password (ConvertTo-SecureString -String "PASSWORD" -Force -AsPlainText)

无论我向 -EndDate 提供什么值(只要它是有效的 System.DateTime),密码都会成功创建,但有效期为 1 年

我已经在 Linux 上的 PS 核心和服务器 2016 上的 PS native 上尝试过此操作

最佳答案

经过大量搜索和测试,我得到了与您相同的结果,根据 postman 的测试,我同意这可能是 New-AzureRmADSpCredential 密码的错误。

此外,如果您想实现凭据永不过期,您可以尝试使用 New-AzureRmADAppCredential 来实现。

注意:这里的ObjectId不是您的ServicePrincipal objectid,它是应用程序注册 objectId,即与 ServicePrincipal 具有相同的名称。

$start = get-date
$end = $start.AddYears(150)
$SecureStringPassword = ConvertTo-SecureString -String "password" -AsPlainText -Force
New-AzureRmADAppCredential -ObjectId xxxxxxxxxxxxxxxxxxx -StartDate $start -EndDate $end -Password $SecureStringPassword

enter image description here

关于azure - New-AzureRmADSpCredential 永不过期的密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51721017/

相关文章:

azure - 更改 Azure 网站订阅

azure - azure 中的自动化 bacpac 导出

linux - PowerShell 中的 grep 和 sed 等价物

azure - 使用 PowerShell 列出 blob、文件、表、队列的已用空间?

powershell - 在 for-each 循环中使用 select-string

azure - 在服务结构中有状态服务中创建唯一的长

azure - 在azure逻辑应用程序中如何从json字符串中提取图像并将其保存在sharepoint中

c# - PowerShell - 从对象方法中写入进度

PowerShell 性能问题

azure - 如何授权对 Azure 管理 API 的调用?