gpt4 book ai didi

azure - 如何让 New-AzureADPolicy 在 azure cloud shell 中工作

转载 作者:行者123 更新时间:2023-12-03 02:11:28 25 4
gpt4 key购买 nike

我能够运行

Install-Module -Name AzureADPreview

但是当我运行时

$policy = New-AzureADPolicy -Definition @('{"TokenLifetimePolicy" {"Version":1,"AccessTokenLifetime":"02:00:00"}}')

遇到这个错误

New-AzureADPolicy: The term 'New-AzureADPolicy' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

如何让该关键字在 Cloud shell 中发挥作用?

最佳答案

我尝试在我的环境中重现相同的情况,但得到了如下相同的错误:

$policy = New-AzureADPolicy -Definition @('{"TokenLifetimePolicy" {"Version":1,"AccessTokenLifetime":"02:00:00"}}') -DisplayName TestPolicy -IsTenantDefault

enter image description here

请注意,在安装AzureADPreview之前,您需要卸载AzureAD模块,如下所示:

Uninstall-Module AzureAD 
Install-Module AzureADPreview
Import-Module AzureADPreview
Get-Module -Name AzureADPreview
connect-AzureAd

enter image description here

我尝试使用以下命令创建策略并成功获得如下结果:

$policy = New-AzureADPolicy -Definition @('{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"02:00:00"}}') -DisplayName "WebPolicyScenario" -IsOrganizationDefault $false -Type "TokenLifetimePolicy"

enter image description here

引用:

Set lifetimes for tokens - Microsoft Entra | Microsoft Docs

关于azure - 如何让 New-AzureADPolicy 在 azure cloud shell 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73274201/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com