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

%3CLINGO-SUB%20id%3D%22lingo-sub-329255%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20PowerShell%20v2%20cmdlets%20not%20working%2C%20e.g.%20Get-AzureADPolicy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-329255%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20worked%20for%20me.%20I%20had%20a%20new%20Win10%20laptop%20and%20installing%20the%20preview%20(v2.0.2.5)%20would%20work%20but%20%3CSTRONG%3EGet-AzureADPolicy%3C%2FSTRONG%3E%20didn't.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20just%20had%20to%20run%20%22UnInstall-Module%20AzureAD%22%20in%20a%20fresh%20elevated%20PowerShell%20console%20and%20then%20the%20preview%20cmdlets%20worked%20perfectly%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-204465%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20PowerShell%20v2%20cmdlets%20not%20working%2C%20e.g.%20Get-AzureADPolicy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-204465%22%20slang%3D%22en-US%22%3EUpdated%20to%20the%20latest%20AzureADPreview%20Module%20(2.0.1.11)%20and%20it%20worked%20fine%20for%20me.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-204464%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20PowerShell%20v2%20cmdlets%20not%20working%2C%20e.g.%20Get-AzureADPolicy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-204464%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20worked.%20Installing%20the%20AzureADPreview%20module%20was%20failing%20as%20there%20were%20too%20many%20conflicting%20commands%20with%20the%20AzureAD%20Module.%20Once%20I%20uninstalled%20AzureAD%20and%20then%20Installed%20AzureADPreview%20(latest%20version%202.0.1.11)%20then%20everything%20worked%20as%20expected.%20Thank%20you%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-204006%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20PowerShell%20v2%20cmdlets%20not%20working%2C%20e.g.%20Get-AzureADPolicy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-204006%22%20slang%3D%22en-US%22%3EFixed%20it%20by%20uninstalling%20all%20AzureAD%20and%20preview%20modules%2C%20then%20installing%20the%20AzureADPreview%20version%202.0.0.7%20like%20this%3A%3CBR%20%2F%3EInstall-Module%20-Name%20AzureADPreview%20-RequiredVersion%202.0.0.7%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-203918%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20PowerShell%20v2%20cmdlets%20not%20working%2C%20e.g.%20Get-AzureADPolicy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-203918%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20the%20same%20issue.%26nbsp%3B%20The%20AzureADPreview%20module%20was%20working%20fine%20with%202.0.0.9%20(I%20think%20that%20was%20the%20version)%20but%20updated%20to%202.0.11%20I%20get%20the%20same%20experience.%26nbsp%3B%20If%20I%20run%20Install-Module%20AzureADPreview%2C%20then%20run%20Connect-AzureAD%2C%20it%20loads%20AzureAD%20module%20and%20the%20Preview%20cmdlets%20can't%20be%20found...%26nbsp%3B%20I%20can't%20run%20Preview%20cmdlets%20anymore.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-197039%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20PowerShell%20v2%20cmdlets%20not%20working%2C%20e.g.%20Get-AzureADPolicy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-197039%22%20slang%3D%22en-US%22%3E%3CP%3EHaving%20same%20issue.%20If%20I%20import%20the%20AzureADPreview%20module%20only%20the%20same%20thing%20occurs%2C%20so%20its%20loading%20the%20AzureAD%20module%20in%20the%20background.%20You%20should%20be%20able%20to%20run%20both%20side%20by%20side%20for%20production.%3C%2FP%3E%3CP%3ENot%20happy.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-90268%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20PowerShell%20v2%20cmdlets%20not%20working%2C%20e.g.%20Get-AzureADPolicy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-90268%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20uninstall%20using%3C%2FP%3E%3CP%3EUnInstall-Module%20AzureAD%3C%2FP%3E%3CP%3Ethen%20install%20the%20preview%20module%3C%2FP%3E%3CP%3EInstall-Module%20AzureADPreview%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-87630%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Azure%20AD%20PowerShell%20v2%20cmdlets%20not%20working%2C%20e.g.%20Get-AzureADPolicy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-87630%22%20slang%3D%22en-US%22%3E%3CP%3EIt%20does%20load%2C%20but%20you%20have%20matching%20cmdlets%20between%20the%20two%20modules%2C%20and%20the%20non-preview%20version%20takes%20precedence.%20Unless%20you%20load%20it%20explicitly%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-87585%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Azure%20AD%20PowerShell%20v2%20cmdlets%20not%20working%2C%20e.g.%20Get-AzureADPolicy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-87585%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20very%20much!%20I%20was%20not%20aware%20that%20I%20had%20to%20import%20the%20module.%20Hope%20this%20wil%20change%20in%20the%20future%20so%20that%20the%20module%20loads%20automatically%20when%20start%20PowerShell%20like%20the%20MSOL%20module%20does.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-87500%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Azure%20AD%20PowerShell%20v2%20cmdlets%20not%20working%2C%20e.g.%20Get-AzureADPolicy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-87500%22%20slang%3D%22en-US%22%3E%3CP%3EWhich%20version%20of%20the%20Preview%20module%20you%20have%2C%20works%20fine%20here%20with%202.0.0.127.%20Make%20sure%20you%20are%20actually%20loading%20the%20correct%26nbsp%3Bmodule%2C%20as%20when%20you%20have%20matching%20cmdlets%20between%20both%20(Connect-AzureAD%20is%20the%20same%20for%20AzureADPreview%20and%20AzureADPreview).%20For%20example%2C%20open%20a%20fresh%20PowerShell%20window%2C%20do%20a%20Import-Module%20AzureADPreview%2C%20connect%26nbsp%3Band%20then%20try%20running%20Get-AzureADPolicy.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-87458%22%20slang%3D%22en-US%22%3ERE%3A%20Azure%20AD%20PowerShell%20v2%20cmdlets%20not%20working%2C%20e.g.%20Get-AzureADPolicy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-87458%22%20slang%3D%22en-US%22%3EOk%20so%20I%20found%20out%20that%20I%20need%20to%20install%20the%20Azure%20AD%20PowerShell%20v2%20preview%20module%20which%20I%20did.%20Unfortunately%20I%20still%20get%20the%20error%20that%20the%20Get-AzureADPolicy%20cmdlet%20is%20not%20recognized.%20I%20can%20use%20tab%20completion%20on%20Get-AzureADP%20and%20also%20Get-Help%20Get-AzureADPolicy%20is%20working.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-87450%22%20slang%3D%22en-US%22%3EAzure%20AD%20PowerShell%20v2%20cmdlets%20not%20working%2C%20e.g.%20Get-AzureADPolicy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-87450%22%20slang%3D%22en-US%22%3E%3CP%3ESorry%20if%20I%20posted%20this%20twice%2C%20to%20me%20it%20seems%20that%20the%20first%20post%20did%20not%20succeed.%3C%2FP%3E%3CP%3EInstalled%26nbsp%3BPowerShellGet%20using%20the%20MSI.%3C%2FP%3E%3CP%3EInstalled%20the%20Azure%20AD%20PowerShell%20v2%20GA%20module%20using%20Install-Module%20AzureAD.%3C%2FP%3E%3CP%3EConnected%20and%20authenticated%20to%20our%20Azure%20AD%20tenant%20successfuly%20using%20Connect-AzureAD%20as%20can%20be%20seen%20below.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3EPS%20C%3A%5CUsers%5CAdministrator%26gt%3B%20connect-azuread%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3EAccount%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Environment%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20TenantId%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20TenantDomain%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20AccountType%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E-------%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20-----------%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20--------%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20------------%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20-----------%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3Exxxxxxx%40xxxxxxxx.nl%26nbsp%3B%26nbsp%3B%26nbsp%3B%20AzureCloud%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20xxxxxxxx-0599-4cd4-8...%20xxxxxxxx.onmicrosof...%20User%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20when%20running%20the%20Get-AzureADPolicy%20I%20get%20the%20error%20that%20this%20cmdlet%20is%20not%20available%20as%20can%20be%20seen%20below.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3EPS%20C%3A%5CUsers%5CAdministrator%26gt%3B%20Get-AzureADPolicy%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EGet-AzureADPolicy%20%3A%20The%20term%20'Get-AzureADPolicy'%20is%20not%20recognized%20as%20the%20name%20of%20a%20cmdlet%2C%20function%2C%20script%20file%2C%20or%20operable%20program.%20Check%20the%20spelling%20of%20the%20name%2C%20or%20if%20a%20path%20was%20included%2C%20verify%20that%20the%20path%20is%20correct%20and%20try%20again.%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EAt%20line%3A1%20char%3A1%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%2B%20Get-AzureADPolicy%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%2B%20~~~~~~~~~~~~~~~~~%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2B%20CategoryInfo%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3A%20ObjectNotFound%3A%20(Get-AzureADPolicy%3AString)%20%5B%5D%2C%20CommandNotFoundException%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2B%20FullyQualifiedErrorId%20%3A%20CommandNotFoundException%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20am%20I%20doing%20wrong%3F%3C%2FP%3E%3CP%3EI%20urgently%20need%20to%20adjust%20the%20token%20lifetimes.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-87450%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20AD%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Occasional Contributor

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.

11 Replies
Highlighted
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.
Highlighted

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.

Highlighted

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.

Highlighted

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

Highlighted

First uninstall using

UnInstall-Module AzureAD

then install the preview module

Install-Module AzureADPreview

Highlighted

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.

Highlighted

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.

Highlighted
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
Highlighted

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

Highlighted
Updated to the latest AzureADPreview Module (2.0.1.11) and it worked fine for me.
Highlighted

This worked for me. I had a new Win10 laptop and installing the preview (v2.0.2.5) would work but Get-AzureADPolicy didn't.

 

I just had to run "UnInstall-Module AzureAD" in a fresh elevated PowerShell console and then the preview cmdlets worked perfectly