goezler

Exchange Server Commands

Apr 10th, 2022 (edited)
967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Move a mailbox to an other DB:
  2. New-MoveRequest -Identity "username@domain.com" -TargetDatabase "DB02"
  3.  
  4. # Display a list of moving mailboxes and percentage:
  5. Get-MoveRequest | Get-MoveRequestStatistics
  6.  
  7. # Remove all completed requests:
  8. Get-MoveRequest -movestatus completed | remove-moverequest
  9.  
  10. # Verify if the mailbox is moved
  11. Get-Mailbox "username@domain.com" | Format-List Database
  12.  
  13. # List mailboxes in a DB
  14. Get-Mailbox -Database "DB_NAME" | ft Name, Alias, WindowsEmailAddress, UserPrincipalName
  15.  
  16. # Display DB Size
  17. Get-MailboxDatabase -status| Select Name, DatabaseSize, AvailableNewMailboxSpace
  18.  
  19. # Export results to a CSV file
  20. | Export-Csv C:\temp\MailboxesDB02.csv -NoTypeInformation -Encoding UTF8 -Delimiter ';'
  21.  
  22. # Set Sending Limit
  23. Set-ReceiveConnector -Identity "Client Frontend MAILSERVER_NAME" -MessageRateLimit 200
  24.  
  25. # Set Static DC / DNS Server for Exchange
  26. Set-ExchangeServer -Identity <Server> -StaticDomainControllers DC-01.dc.local,DC-02.dc.local
  27. Set-ExchangeServer -Identity <Server> -StaticGlobalCatalogs DC-01.dc.local,DC-02.dc.local
  28. ___________________________________________________________________________________________________________________
  29. # Set Exchange URLs
  30.  
  31. Variables:
  32. $OutlookHostname = "SERVERNAME.DOMAIN.COM"
  33. $ExternalOutlookHostname = "SERVERNAME.DOMAIN.COM"
  34. __________________________________________________________
  35.  
  36. #Hostname für Autodiscover:
  37. $AutodiscoverHostname = "autodiscover.domain.com"
  38. ___________________________________________________________
  39. #ServerName
  40. $Server = "LOCAL_EXCHANGE-SERVER_NAME"
  41. ___________________________________________________________
  42. #OWA
  43. $owa = "https://" + "$OutlookHostname" + "/owa"
  44. $owaext = "https://" + "$ExternalOutlookHostname" + "/owa"
  45. write-host "OWA URL:" $owa
  46. Get-OwaVirtualDirectory -Server $Server | Set-OwaVirtualDirectory -internalurl $owa -externalurl $owaext
  47.  
  48. #ECP
  49. $ecp = "https://" + "$OutlookHostname" + "/ecp"
  50. $ecpext = "https://" + "$ExternalOutlookHostname" + "/ecp"
  51. write-host "ECP URL:" $ecp
  52. Get-EcpVirtualDirectory -server $Server | Set-EcpVirtualDirectory -internalurl $ecp -externalurl $ecpext
  53.  
  54. #EWS
  55. $ews = "https://" + "$OutlookHostname" + "/EWS/Exchange.asmx"
  56. $ewsext = "https://" + "$ExternalOutlookHostname" + "/EWS/Exchange.asmx"
  57. write-host "EWS URL:" $ews
  58. Get-WebServicesVirtualDirectory -server $Server | Set-WebServicesVirtualDirectory -internalurl $ews -externalurl $ewsext -confirm:$false -force
  59.  
  60. #ActiveSync
  61. $eas = "https://" + "$OutlookHostname" + "/Microsoft-Server-ActiveSync"
  62. $easext = "https://" + "$ExternalOutlookHostname" + "/Microsoft-Server-ActiveSync"
  63. write-host "ActiveSync URL:" $eas
  64. Get-ActiveSyncVirtualDirectory -Server $Server | Set-ActiveSyncVirtualDirectory -internalurl $eas -externalurl $easext
  65.  
  66. #OAB
  67. $oab = "https://" + "$OutlookHostname" + "/OAB"
  68. $oabext = "https://" + "$ExternalOutlookHostname" + "/OAB"
  69. write-host "OAB URL:" $oab
  70. Get-OabVirtualDirectory -Server $Server | Set-OabVirtualDirectory -internalurl $oab -externalurl $oabext
  71.  
  72. #MAPIoverHTTP
  73. $mapi = "https://" + "$OutlookHostname" + "/mapi"
  74. $mapiext = "https://" + "$ExternalOutlookHostname" + "/mapi"
  75. write-host "MAPI URL:" $mapi
  76. Get-MapiVirtualDirectory -Server $Server| Set-MapiVirtualDirectory -internalurl $mapi -externalurl $mapiext
  77.  
  78. #Outlook Anywhere
  79. write-host "OA Hostname:" $OutlookHostname
  80. Get-OutlookAnywhere -Server $Server| Set-OutlookAnywhere -internalhostname $OutlookHostname -InternalClientsRequireSsl $true
  81.  
  82. #Autodiscover SCP
  83. $autodiscover = "https://" + "$OutlookHostname" + "/Autodiscover/Autodiscover.xml"
  84. write-host "Autodiscover URL:" $autodiscover
  85. Get-ClientAccessService $Server | Set-ClientAccessService -AutoDiscoverServiceInternalUri $autodiscover
Add Comment
Please, Sign In to add comment