Skip to content

Instantly share code, notes, and snippets.

@hunzo
Created February 1, 2022 07:55
Show Gist options
  • Select an option

  • Save hunzo/e3259f84423e764199a30614c9abadd3 to your computer and use it in GitHub Desktop.

Select an option

Save hunzo/e3259f84423e764199a30614c9abadd3 to your computer and use it in GitHub Desktop.
$User = "global_admin_account@domain.com"
$PWord = ConvertTo-SecureString -String "global_admin_password" -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
$exosession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid -Credential $cred -Authentication Basic -AllowRedirection
Import-PSSession $exosession
Get-Mailbox -Identity "email_users@domain.com" | select UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAndForward
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment