ExchangePowershell: Difference between revisions

From Piszczynski
piszczynski>Aleks
No edit summary
piszczynski>Aleks
No edit summary
Line 27: Line 27:
Add full access permission to all mailboxes to an account:
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
*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>

Revision as of 13:18, 15 January 2020

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

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
  • Send on Behalf
    • This will grant Charles permissions to send on behalf of Gert.
      • Set-Mailbox gert.mailbox -GrantSendOnBehalfTo charles.surname
  • Send As
    • This will grant Charles permissions to send as Gert.
      • Add-ADPermission gert.mailbox -ExtendedRights Send-As -user charles.surname
  • Full Mailbox Access
    • This will grant Charles full access to Gert's mailbox.
      • Add-MailboxPermission -Identity gert.mailbox -User charles.surname


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>