Some Exchange Powershells

1. How to remove disconnected mailboxes:

Remove-StoreMailbox –database “DB2” –identity “Chakka Rajith” –MailboxState Disabled

If you want to remove all disconnected mailboxes from a database, run the following command

Get-MailboxStatistics –Database “dbname” | Where-Object {$_.DisconnectReason –eq “Disabled”} | ForEach {Remove-StoreMailbox –Database $_.database –identity $_.mailboxguid –MailboxState Disabled

If you want to remove all soft-deleted mailboxes from a database, run the following command

Get-MailboxStatistics –Database “dbname” | Where-Object {$_.DisconnectReason –eq “Softdeleted”} | ForEach {Remove-StoreMailbox –Database $_.database –identity $_.mailboxguid –MailboxState softdeleted

2. Point Exchange RPC client access server:

Get-MailboxDatabase | fl RpcClientAccessserver

Set-MailboxDatabase -RpcClientAccessServer “outlook.domain.com”

3. Clean mailboxes to get them shown in the disconnected mailboxes:

Get-Mailboxstatistics -server active-mail | Where-Object { $_.DisconnectDate -ne $null } | FL DisplayName,LegacyDN,ItemCount,OriginatingServer

Clean a certain mailbox database with this command:

Clean-MailboxDatabase "Mailbox Database"

Clean all databases with this command:

Get-MailboxDatabase | Clean-MailboxDatabase

4. Assign full access to the all mailboxes on the mailbox database:

Get-MailboxDatabase -identity [mailbox database name] | Add-ADPermission -user [username] -AccessRights GenericAll

5. Assign full access to individual mailbox:

get-user -identity domainUSR | Add-MailboxPermission -User domainUSR -AccessRights 'FullAccess'

6. Enable anonymous authentication on receive connector:

add-adpermission 'Relay' -User 'NT AUTHORITYANONYMOUS LOGON' -ExtendedRights ms-Exch-SMTP-Accept-Authoritative-Domain-Sender

[@more@]
请使用浏览器的分享功能分享到微信等