Home

Azure AD PowerShell v2 cmdlets not working, e.g. Get-AzureADPolicy

Han Valk
Occasional Contributor

Azure AD PowerShell v2 cmdlets not working, e.g. Get-AzureADPolicy

Sorry if I posted this twice, to me it seems that the first post did not succeed.

Installed PowerShellGet using the MSI.

Installed the Azure AD PowerShell v2 GA module using Install-Module AzureAD.

Connected and authenticated to our Azure AD tenant successfuly using Connect-AzureAD as can be seen below.

 

PS C:\Users\Administrator> connect-azuread

Account                 Environment             TenantId                TenantDomain            AccountType
-------                 -----------             --------                ------------            -----------
xxxxxxx@xxxxxxxx.nl    AzureCloud              xxxxxxxx-0599-4cd4-8... xxxxxxxx.onmicrosof... User

 

But when running the Get-AzureADPolicy I get the error that this cmdlet is not available as can be seen below.

 

PS C:\Users\Administrator> Get-AzureADPolicy
Get-AzureADPolicy : The term 'Get-AzureADPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-AzureADPolicy
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-AzureADPolicy:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

 

What am I doing wrong?

I urgently need to adjust the token lifetimes.

10 Replies

RE: Azure AD PowerShell v2 cmdlets not working, e.g. Get-AzureADPolicy

Ok so I found out that I need to install the Azure AD PowerShell v2 preview module which I did. Unfortunately I still get the error that the Get-AzureADPolicy cmdlet is not recognized. I can use tab completion on Get-AzureADP and also Get-Help Get-AzureADPolicy is working.

Re: RE: Azure AD PowerShell v2 cmdlets not working, e.g. Get-AzureADPolicy

Which version of the Preview module you have, works fine here with 2.0.0.127. Make sure you are actually loading the correct module, as when you have matching cmdlets between both (Connect-AzureAD is the same for AzureADPreview and AzureADPreview). For example, open a fresh PowerShell window, do a Import-Module AzureADPreview, connect and then try running Get-AzureADPolicy.

Re: RE: Azure AD PowerShell v2 cmdlets not working, e.g. Get-AzureADPolicy

Thank you very much! I was not aware that I had to import the module. Hope this wil change in the future so that the module loads automatically when start PowerShell like the MSOL module does.

Re: RE: Azure AD PowerShell v2 cmdlets not working, e.g. Get-AzureADPolicy

It does load, but you have matching cmdlets between the two modules, and the non-preview version takes precedence. Unless you load it explicitly :)

Re: Azure AD PowerShell v2 cmdlets not working, e.g. Get-AzureADPolicy

First uninstall using

UnInstall-Module AzureAD

then install the preview module

Install-Module AzureADPreview

Re: Azure AD PowerShell v2 cmdlets not working, e.g. Get-AzureADPolicy

Having same issue. If I import the AzureADPreview module only the same thing occurs, so its loading the AzureAD module in the background. You should be able to run both side by side for production.

Not happy.

Re: Azure AD PowerShell v2 cmdlets not working, e.g. Get-AzureADPolicy

I have the same issue.  The AzureADPreview module was working fine with 2.0.0.9 (I think that was the version) but updated to 2.0.11 I get the same experience.  If I run Install-Module AzureADPreview, then run Connect-AzureAD, it loads AzureAD module and the Preview cmdlets can't be found...  I can't run Preview cmdlets anymore.

Re: Azure AD PowerShell v2 cmdlets not working, e.g. Get-AzureADPolicy

Fixed it by uninstalling all AzureAD and preview modules, then installing the AzureADPreview version 2.0.0.7 like this:
Install-Module -Name AzureADPreview -RequiredVersion 2.0.0.7

Re: Azure AD PowerShell v2 cmdlets not working, e.g. Get-AzureADPolicy

This worked. Installing the AzureADPreview module was failing as there were too many conflicting commands with the AzureAD Module. Once I uninstalled AzureAD and then Installed AzureADPreview (latest version 2.0.1.11) then everything worked as expected. Thank you

Re: Azure AD PowerShell v2 cmdlets not working, e.g. Get-AzureADPolicy

Updated to the latest AzureADPreview Module (2.0.1.11) and it worked fine for me.
Related Conversations
Conditional Access based on location only?
Jim Kacerguis in Azure on
2 Replies
How to locate storage account belongs to azure VM disk
Suhag Desai in Azure on
7 Replies
Report on users with MFA Enabled
Damon Betlow in Azure Active Directory on
15 Replies
Azure AD Connect on a DC
Glenn V in Azure Active Directory on
15 Replies
Different method to create azure virtual machine
Suhag Desai in Azure on
3 Replies
Some basic questions above Azure
AUser ZUser in Azure on
6 Replies