I was able to run
Install-Module -Name AzureADPreview
But when I run
$policy = New-AzureADPolicy -Definition @('{"TokenLifetimePolicy" {"Version":1,"AccessTokenLifetime":"02:00:00"}}')
It run into this error
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.
How do I get this keyword to work in cloud shell?
I tried to reproduce the same in my environment and got the same error as below:
$policy = New-AzureADPolicy -Definition @('{"TokenLifetimePolicy" {"Version":1,"AccessTokenLifetime":"02:00:00"}}') -DisplayName TestPolicy -IsTenantDefault
Please note that, before installing AzureADPreview
you need uninstall AzureAD
Module like below:
Uninstall-Module AzureAD
Install-Module AzureADPreview
Import-Module AzureADPreview
Get-Module -Name AzureADPreview
connect-AzureAd
I tried to create the policy by using the below command and got the results successfully like below:
$policy = New-AzureADPolicy -Definition @('{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"02:00:00"}}') -DisplayName "WebPolicyScenario" -IsOrganizationDefault $false -Type "TokenLifetimePolicy"
Reference: