Simple update can be made to the script to make it work in PS7 with EXO 2 and AZ module Get/Set AzureAD User can be replaced with Get-AzAdUser and Update-AzADUser -ObjectID $mailbox.userprincipalname -EnableAccount $false