locked
Powershell AzureAz Commands Return Not Recognized RRS feed

  • Question

  • I am attempting to load azure az on my powershell v 5.1. At this point I am able to get it to login to and connect to the azure servers, however I cannot execute the commands I need to execute to disable the connection between my local AD and the cloud azure AD.

    The list of commands I have run up to this include the following.

    if ($PSVersionTable.PSEdition -eq 'Desktop' -and (Get-Module -Name AzureRM -ListAvailable)) {
        Write-Warning -Message ('Az module not installed. Having both the AzureRM and ' +
          'Az modules installed at the same time is not supported.')
    } else {
        Install-Module -Name Az -AllowClobber -Scope CurrentUser
    
    PS C:\WINDOWS\system32> Connect-AzAccount 

    PS C:\WINDOWS\system32> Set-ExecutionPolicy Unrestricted

    PS C:\WINDOWS\system32> Install-Module -Name AzureADPreview

    PS C:\WINDOWS\system32> Import-Module Az.Accounts


    This is the error I receive when I attempt to run --> Set-MsolDirSyncEnabled -EnableDirSync $false

    PS C:\WINDOWS\system32> Set-MsolDirSyncEnabled -EnableDirSync $false
    Set-MsolDirSyncEnabled : The term 'Set-MsolDirSyncEnabled' 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
    + Set-MsolDirSyncEnabled –EnableDirSync $false
    + ~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (Set-MsolDirSyncEnabled:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    



    Monday, July 13, 2020 9:50 PM

All replies

  • Hi klhaviland,

    You will need to install Module MSOnline before you execute the command “Set-MsolDirSyncEnabled”.

    Make sure you have installed required software and connected to Azure AD for your Office 365 subscription referring to this document.

    Here is the reference:

    Turn off directory synchronization for Microsoft 365.

    https://docs.microsoft.com/en-us/office365/enterprise/turn-off-directory-synchronization

    Best regards,

    Chelsea Wu


    "SharePoint" forums will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "SharePoint" forums' new home on Microsoft Q&A !

    Tuesday, July 14, 2020 2:44 AM
  • Is there a recommended way that is separate from upgrading Powershell 5.1 that I should be using to connect to the azure ad?


    Also, If I disable the sync between the local active directory and azure will I be able to add it back in at a later time with a different FQDN?

    • Edited by klhaviland Thursday, July 16, 2020 2:00 PM
    Thursday, July 16, 2020 1:47 PM
  • Hi klhaviland,

    Microsoft Azure Active Directory Module for Windows PowerShell module is supported on PowerShell version 5.1 or later, so there is no need to upgrade as well as you have the required software installed on your machine. Just install the module by running

    Install-Module MSOnline

    Then connect to Azure AD by running

    Connect-MsolService

    And for the second question: You can disable and reconfigure the sync between Azure AD and local AD at any time.

    Here is a document for guidance on how to use multiple top-level domains and subdomains for your reference:

    Multiple Domain Support for Federating with Azure AD.

    https://docs.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-install-multiple-domains

    ---

    This “Microsoft Online: Administration Center” Forum will be migrating to a new home on Microsoft Q&A, please refer to this sticky post for more details.

    Best regards,

    Chelsea Wu


    "SharePoint" forums will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "SharePoint" forums' new home on Microsoft Q&A !

    Friday, July 17, 2020 2:59 AM
  • Hi,

    Please remember to update this thread if you have any progress.

    Thank you for your understanding.

    ---

    This “Microsoft Online: Administration Center” Forum will be migrating to a new home on Microsoft Q&A, please refer to this sticky post for more details.

    Best regards,

    Chelsea Wu

    "SharePoint" forums will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "SharePoint" forums' new home on Microsoft Q&A !

    Monday, July 20, 2020 6:04 AM
  • Hi,

    This forum will be locked down, if you need further assistance with this issue, you can continue to post in here before 8/10/2020. It is recommended to create a new question on Microsoft Q&A, we will continue to support you on the new home.

    Thank you for your understanding.

    Best regards,

    Chelsea Wu


    "SharePoint" forums will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "SharePoint" forums' new home on Microsoft Q&A !

    Tuesday, August 4, 2020 2:32 AM