Cloud Knowledge

Your Go-To Hub for Cloud Solutions & Insights

Advertisement

How to Use Basic PowerShell Commands for Azure AD

How to Use PowerShell Cmdlets for Active Directory

Managing Active Directory (AD) and Azure Active Directory (Azure AD) often involves the use of PowerShell cmdlets for tasks ranging from syncing user accounts to diagnosing network connectivity. Below is a detailed guide to some of the most commonly used cmdlets and their descriptions.

Active Directory Synchronization Cmdlets

  1. Get-ADSyncAADCompanyFeature
    Retrieves the configuration of features enabled for your Azure AD Connect environment.

  2. Get-ADSyncScheduler
    Displays the current configuration of the Azure AD Connect scheduler, including synchronization settings.

  3. Start-ADSyncSyncCycle -PolicyType Delta
    Initiates a delta synchronization cycle, syncing only recent changes between on-premises AD and Azure AD.

  4. Start-ADSyncSyncCycle -PolicyType Initial
    Starts a full synchronization cycle, syncing all objects between on-premises AD and Azure AD.

  5. Set-ADSyncScheduler -SyncCycleEnabled $false
    Disables automatic synchronization cycles.

  6. Set-ADSyncScheduler -SyncCycleEnabled $true
    Re-enables automatic synchronization cycles.

  7. Set-ADSyncScheduler -CustomizedSyncCycleInterval 00:15:00
    Sets a custom synchronization interval, such as 15 minutes in this example.

  8. Set-ADSyncAADCompanyFeature -devicewriteback $true
    Enables device writeback to synchronize devices from Azure AD to on-premises AD.

Validation and Diagnosis Cmdlets

  1. Confirm-DnsConnectivity
    Validates DNS connectivity for synchronization processes.

  2. Confirm-ForestExists
    Checks if the specified AD forest exists.

  3. Confirm-FunctionalLevel
    Ensures the functional level of your AD forest/domain meets the requirements.

  4. Confirm-NetworkConnectivity
    Tests network connectivity for synchronization.

  5. Confirm-TargetsAreReachable
    Confirms that all target systems are accessible.

  6. Confirm-ValidDomains
    Verifies the validity of the domains in your AD configuration.

  7. Confirm-ValidEnterpriseAdminCredentials
    Checks if enterprise admin credentials are valid for the AD environment.

  8. Start-ConnectivityValidation
    Runs connectivity validation for synchronization.

  9. Start-NetworkConnectivityDiagnosisTools
    Initiates network diagnosis tools for troubleshooting.

Azure Active Directory Management Cmdlets

  1. Install-Module -Name AzureAD
    Installs the Azure AD PowerShell module for managing Azure Active Directory.

  2. Import-Module AzureAD
    Imports the Azure AD module into your session.

  3. Connect-AzureAD -Credential (Get-Credential)
    Connects to Azure Active Directory using provided credentials.

  4. Get-AzureADUser
    Retrieves details of all Azure AD users.

  5. Get-AzureADUser -ObjectID <UserEmail>
    Fetches details for a specific Azure AD user.

  6. Get-AzureADUser | Export-Csv -Path “C:\Temp\AllUsers.csv”
    Exports all Azure AD user details to a CSV file.

  7. Disconnect-AzureAD
    Disconnects from the Azure AD session.

  8. Install-Module -Name AzureADPreview
    Installs the preview version of the Azure AD module.

Additional Commands for Azure AD and MSOnline

  1. Get-AzureADTenantDetail
    Displays details about your Azure AD tenant.

  2. Get-Command -Module AzureAD
    Lists all cmdlets available in the Azure AD module.

  3. Install-Module -Name MSOnline
    Installs the MSOnline module for managing Microsoft Online services.

  4. Connect-MsolService
    Connects to Microsoft Online services for managing Azure AD.

  5. Get-MsolUser
    Retrieves information about users in your Azure AD environment.

Summary

These cmdlets are essential for administrators managing AD and Azure AD environments. From synchronization tasks to advanced diagnostics and user management, these commands streamline operations and ensure efficient directory services management. Whether you’re a seasoned admin or a beginner, keeping this cheat sheet handy can greatly enhance your productivity.

For more details, explore official documentation and resources.

 Happy scripting!

Leave a Reply

Your email address will not be published. Required fields are marked *