Different modules sometimes with overlapping capabilities are available from Microsoft for managing Azure capabilities. This tries to collect some of these scenarios for reference.
Used to manage Azure subscription and services related use-cases. Limited capability for Azure AD.
Install-Module Az
Provides wrapper over MS Graph API. MSOnline is an older version using V1 Graph API and Azure AD uses the new API.
TODO:
- Need to understand relevance over MS Graph module
- Feature comparison between Azure AD V2 & MSOnline.
Install-Module AzureAD
Install-Module MSOnline
OR
Install-Module AzureADPreview
Install-Module MSOnline
Wrapper over graph API. Run the second line below to select beta profile.
Install-Module Microsoft.Graph
Install-module Microsoft.Graph.Identity.Signins
Select-MgProfile -Name beta
Install-Module -Name ExchangeOnlineManagement
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
Install-Module -Name MicrosoftTeams
Before running any command, you may have to execute the following command
Set-ExecutionPolicy RemoteSigned
Authenticate once and then session is cached.
This uses browser popup to authenticate user and capture token for future calls. Seems to be active till powershell is exited.
Connect-AzAccount
$AzureAdCred = Get-Credential
Connect-AzureAD -Credential $AzureAdCred
OR
$Msolcred = Get-credential
Connect-MsolService -Credential $MsolCred
Delegated access uses device flow to authenticate user and getting the token for specific scopes. This token is persisted for the PS session.
Connect-MgGraph -Scopes UserAuthenticationMethod.ReadWrite.All
There is no API available to retrieve all users with all details.
$users = Get-AzureADUser -All $true
$users | forEach-Object {$_|select ObjectId, Mobile}| ConvertTo-Csv
$user=Get-MgUser -All
$users | forEach-Object {$_|select Id, MobilePhone}| ConvertTo-Csv
Update-Module
Powershell modules uninstallation must be done one module at a time. Use following scipt for cleanups
Uninstall-Module <Microsoft.Graph|Az>
Get-InstalledModule <Microsoft.Graph.*|Az.*> | %{ if($_.Name -ne "Microsoft.Graph.Authentication"){ Uninstall-Module $_.Name } }
Uninstall-Module Microsoft.Graph.Authentication
Create and configure sensitivity labels and then publish them and sync the labels with Azure AD
Execute-AzureAdLabelSync
Enabling Group Sensitivity Level
Connect-AzureAD
$grpUnifiedSetting = (Get-AzureADDirectorySetting | where -Property DisplayName -Value "Group.Unified" -EQ)
$template = Get-AzureADDirectorySettingTemplate -Id 62375ab9-6b52-47ed-826b-58e47e0e304b
$setting = $template.CreateDirectorySetting()
$Setting["EnableMIPLabels"] = "True"
# if running for the first time.
# New-AzureADDirectorySetting -DirectorySetting $Setting
# If running new
# Set-AzureADDirectorySetting -Id $grpUnifiedSetting.Id -DirectorySetting $setting