Azure Automation Accounts allow you to define Runbooks for performing tasks. These Runbooks may be configured to run as cloud-native or on Hybrid Workers (aka VM hosts).


This example shows a method to connect to Exchange on-premises from a Hybrid Worker VM.

$SVC_ACCOUNT = Get-AutomationVariable -Name SVC_ACCOUNT
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange `
  -ConnectionUri http://<serverName>/PowerShell/ `
  -Authentication Kerberos `
  -Credential (Get-AutomationPSCredential -Name $SVC_ACCOUNT)
# Import-PSSession $exchangeSession -DisableNameChecking (this will hang in Azure automation)
Import-Module -function Get-RemoteMailbox, Enable-RemoteMailbox (Import-PSSession -Session $exchangeSession -DisableNameChecking -AllowClobber ) -Global
# Run your exchange cmdlets
# ...
Remove-PSSession $exchangeSession