Friday, May 25, 2018

Solve problem with missing Get-AzureADDirectorySetting and Set-AzureADDirectorySetting PowerShell cmdlets

If you want to play with Office 365 classifications you will need to configure tenant-level directory settings which contains available values which can be used for groups’ classifications. You may do it using Get-AzureADDirectorySetting and Set-AzureADDirectorySetting cmdlets like shown in the following article: Classifications for Office365 Groups and Microsoft Teams. But if you will follow this article and install both AzureAD and AzureADPreview modules from PowerShell gallery:

Install-Module AzureAD
Install-Module AzureADPreview

and then will connect to Azure AD using command:

Connect-AzureAD

and after that will try to use Get-AzureADDirectorySetting cmdlet you may get the following error:

The term 'Get-AzureADDirectorySetting' is not recognized as the name of a cmdlet,function, script file, or operable program

The problem is that on the moment of writing this post Get-AzureADDirectorySetting cmdlet was defined only in AzureADPreview module. You may check it if will execute the following command:

man Get-AzureADDirectory*

For me it produced the following result:

Name                              Category  Module                    Synopsis
----                              --------  ------                    --------
Get-AzureADDirectoryRole          Cmdlet    AzureADPreview            Gets a directory role.
Get-AzureADDirectoryRoleMember    Cmdlet    AzureADPreview            Gets members of a directory role.
Get-AzureADDirectoryRoleTemplate  Cmdlet    AzureADPreview            Gets directory role templates.
Get-AzureADDirectorySetting       Cmdlet    AzureADPreview            Gets a directory setting.
Get-AzureADDirectorySettingTem... Cmdlet    AzureADPreview            Gets a directory setting template.
Get-AzureADDirectoryRoleMember    Cmdlet    AzureAD                   Get-AzureADDirectoryRoleMember...
Get-AzureADDirectoryRole          Cmdlet    AzureAD                   Get-AzureADDirectoryRole...
Get-AzureADDirectoryRoleTemplate  Cmdlet    AzureAD                   Get-AzureADDirectoryRoleTemplate..

As you can see Get-AzureADDirectorySetting cmdlet is defined in AzureADPreview.

So solution is to start new PowerShell session and connect to Azure AD using Connect-AzureAD from AzureADPreview module:

AzureADPreview\Connect-AzureAD

After that Get-AzureADDirectorySetting and Set-AzureADDirectorySetting cmdlets should become available.

9 comments:

  1. Many thanks for this. I have the same problem. I follow your steps but I am still unable to run the cmdlet. Any ideas what else to try?

    ReplyDelete
  2. The AzureADPreview can't be installed if you have the older AzureAD pack installed. I'm not sure if you could at the time of this article, but it errors out now.
    https://windowstechpro.com/unable-to-install-azureadpreview-module/

    ReplyDelete
  3. Thanks to all and especially @ Rev. J.J. - as that was my problem and had to uninstall it the old module version.

    ReplyDelete
  4. Don't forget to run 'Install-Module AzureADPreview' with the parameter '-AllowClobber' if you've already installed the module 'AzureAD'. Otherwise you'll get an enormous error stating that all cmdlts already exist. Somewhere at the bottom of the wall of red text, it gives you the tip to use '-AllowClobber', but it's easy to miss.

    ReplyDelete
  5. uninstalled AzureAD and installed "install-module azureadpreview -AllowClobber" worked for me.

    ReplyDelete
    Replies
    1. It worked for me, able to list synopsis but still it says Get-AzureADDirectorySetting is not recognized

      Delete
  6. You may need to uninstall the AzureAD module entirely to get it to run the AzureADPreview cmdlets

    ReplyDelete