piszczynski>Aleks No edit summary |
piszczynski>Aleks |
||
Line 53: | Line 53: | ||
== Exchange issues Powershell== | == Exchange issues Powershell== | ||
Get active backend components | |||
*Get-ServerComponentState <ServerName> | ft Component,State –Autosize | |||
Check the Database availability groups cmdlet - use to find out if exchange server is the Primary or Secondary | Check the Database availability groups cmdlet - use to find out if exchange server is the Primary or Secondary | ||
Line 76: | Line 80: | ||
Get the log for the cluster | Get the log for the cluster | ||
*Get-ClusterLog -Destination <File pathway> | *Get-ClusterLog -Destination <File pathway> | ||
== Set remote mailbox for hybrid / shared mailboxes == | == Set remote mailbox for hybrid / shared mailboxes == |
Revision as of 18:54, 4 November 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
- $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
Hide O365 group from GAL ( as this cannot be done on admin portal )
- Set-UnifiedGroup <group> -HiddenFromAddressListsEnabled $true
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>
Get all disconnected mailboxes:
- $dbs = Get-MailboxDatabase; $dbs | foreach {Get-MailboxStatistics -Database $_.DistinguishedName} | where {$_.DisconnectReason -eq "Disabled"} | Format-Table DisplayName,Database,DisconnectDate
- Get-OutlookProvider | fl
- Get-OutlookAnywhere | fl
- Get-ClientAccessServer | fl
- Get-ActiveSyncVirtualDirectory | fl
- Get-AutodiscoverVirtualDirectory | fl
- Get-EcpVirtualDirectory | fl
- Get-OabVirtualDirectory | fl
- Get-OwaVirtualDirectory | fl
- Get-PowerShellVirtualDirectory | fl
- Get-WebServicesVirtualDirectory | fl
- Get-SendConnector | Where-Object {$_.Enabled -eq $true} | fl
Exchange issues Powershell
Get active backend components
- Get-ServerComponentState <ServerName> | ft Component,State –Autosize
Check the Database availability groups cmdlet - use to find out if exchange server is the Primary or Secondary
- Get-DatabaseAvailabilityGroup
You can get all the details you need by using the following command:
- Get-DatabaseAvailabilityGroup | fl
- Get-DatabaseAvailabilityGroup -status
Sometimes the witness will fail, you can check the status of the witness by using the cluster resource cmdlet:
- ipmo failoverclusters
- Get-ClusterResource
This will tell you where the witness stores the file. If the DAG finds the resource unrelibale it might mark it as failed - you can restart this by using start-cluster resource:
- Get-ClusterResource | Start-ClusterResource
Get the log for the cluster
- Get-ClusterLog -Destination <File pathway>
For when there is on-prem and O365 mailboxes
- Need a local user in domain for the shared mailbox for permissions
In Office 365:
1. Get-Mailbox nameofmailbox@domain.com | fl ExchangeGuid
In Exchange on-premise powershell:
2. Enable-RemoteMailbox nameofmailbox@domain.com -RemoteRoutingAddress nameofmailbox@domain.mail.onmicrosoft.com
3. Set-RemoteMailbox nameofmailbox@domain.com -ExchangeGuid <GUID recorded from step 1>