Connect to O365 Exchange
- $UserCredential = Get-Credential
- $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
- Import-PSSession $Session -DisableNameChecking
- $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Then to close the session
- Remove-PSSession $Session
Handy Commands for Exchange Powershell
- Add permission to calendar:
- This will give a user permissions to another calendar
- Set-MailboxFolderPermission “CalendarName:\calendar” –User default –AccessRights reviewer
- This will give a user permissions to another calendar
- Send on Behalf
- This will grant Charles permissions to send on behalf of Gert.
- Set-Mailbox gert.mailbox -GrantSendOnBehalfTo charles.surname
- This will grant Charles permissions to send on behalf of Gert.
- Send As
- This will grant Charles permissions to send as Gert.
- Add-ADPermission gert.mailbox -ExtendedRights Send-As -user charles.surname
- This will grant Charles permissions to send as Gert.
- Full Mailbox Access
- This will grant Charles full access to Gert's mailbox.
- Add-MailboxPermission -Identity gert.mailbox -User charles.surname
- This will grant Charles full access to Gert's mailbox.
Add full access permission to all mailboxes to an account:
- Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox') -and (Alias -ne 'Admin')} | Add-MailboxPermission -User UserAccount@domain.com -AccessRights fullaccess -InheritanceType all -AutoMapping:$False
Add Send as permissions to mailboxes:
- $UserMailboxes = Get-Mailbox | Where {$_.RecipientTypeDetails -eq “<Type of mailbox>”}
- $UserMailboxes | Add-RecipientPermission -AccessRights SendAs –Trustee <identity>