Die wichtigsten Exchange 2010 Befehle

Hallo zusammen,

Während den Vorbereitungen zu den Exchange 2010 Prüfungen und während meiner Arbeit ist diese Sammlung von Exchange 2010 befehlen entstanden. Nun habe ich mich dazu entschlossen diese zu Veröffentlichen.

Prepare Active Directory
http://technet.microsoft.com/en-us/library/bb125224.aspx
setup /PrepareLegacyExchangePermissions or setup /pl (if Exchange 2003 present)
setup /PrepareSchema or setup /ps
setup /PrepareAD [/OrganizationName (CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=<root domain>)
setup /PrepareDomain or setup /PrepareDomain:<FQDN of domain you want to prepare>


AD Site Link
http://technet.microsoft.com/en-us/library/bb123696.aspx
Set-AdSiteLink -Identity DEFAULT_IP_SITE_LINK -ExchangeCost 25 -MaxMessageSize 10MB

http://technet.microsoft.com/en-us/library/bb232079.aspx
Set-AdSite "Site A" -HubSiteEnabled $true17:00 15.04.2010

Understanding Message Routing
http://technet.microsoft.com/en-us/library/aa998825.aspx


Install
Die Komponenten auf dem Server können mit zwei Methoden auf den Server installiert werden.

ServerManagerCmd -ip %ExchangeSource%\scripts\Exchange-all.xml -Restart
ServerManagerCmd -ip %ExchangeSource%\scripts\Exchange-base.xml -Restart
ServerManagerCmd -ip %ExchangeSource%\scripts\Exchange-cadb.xml -Restart
ServerManagerCmd -ip %ExchangeSource%\scripts\Exchange-cas.xml -Restart
ServerManagerCmd -ip %ExchangeSource%\scripts\Exchange-eca.xml -Restart
ServerManagerCmd -ip %ExchangeSource%\scripts\Exchange-edge.xml -Restart
ServerManagerCmd -ip %ExchangeSource%\scripts\Exchange-mbx.xml -Restart
ServerManagerCmd -ip %ExchangeSource%\scripts\Exchange-typical.xml -Restart
ServerManagerCmd -ip %ExchangeSource%\scripts\Exchange-um.xml -Restart

Powershell Import-Module ServerManager
Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server,Web-ISAPI-Ext,Web-Digest-Auth,Web-Dyn-Compression,NET-HTTP-Activation,RPC-Over-HTTP-Proxy -Restart
sc config NetTcpPortSharing start=auto (CAS Server)


Unattended Install
Setup.com /M:Install /R:C,H,M,T /OrganizationName "First Organisation"
Cas (or HT, or C)
HubTransport (or HT, or H)
Mailbox (or MB, or M)
UnifiedMessaging (or UM, or U)
ManagementTools (or MT, or T)


Language Packs
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=4ba91cf8-dafa-4328-9edc-2052fe8347fc#tm

UM Language Pack
Setup.com /AddUmLanguagePack:de-DE
Setup.com /RemoveUmLanguagePack:de-DE /s:[Path to UM LanguagePack]


Transport
Get-TransportConfig
Set-TransportConfig -ShadowRedundancyEnabled $true
Set-TransportConfig -ShadowHeartbeatTimeoutInterval 00:06:00 -ShadowHeartbeatRetryCount 5
Set-TransportConfig -ShadowMessageAutoDiscardInterval 04:00:00
Set-ReceiveConnector "From the Internet" -MaxAcknowledgementDelay 00:00:15.

Set-TransportConfig -ExternalPostmasterAddress postmaster@contoso.com

Accepted Domain
New-AcceptedDomain -DomainName Contoso.com -DomainType Authoritative -Name Contoso

Recipient Policy
new-EmailAddressPolicy -Name 'destination.com' -IncludedRecipients 'MailboxUsers, Resources, MailGroups' -Priority 'Lowest' -EnabledEmailAddressTemplates 'SMTP:%g.%s@destination.com','smtp:%g.%s@destination.net'
update-EmailAddressPolicy -Identity 'destination.com'


Edge
New-EdgeSubscription -FileName "C:\EdgeSubscriptionInfo.xml" (On Edge Server)
New-EdgeSubscription -filename "C:\EdgeSubscriptionInfo.xml" -CreateInternetSendConnector $true - CreateInboundSendConnector $true -site "Default-First-Site-Name"
Test-EdgeSynchronization
Start-EdgeSynchronization
Get-EdgeSubscriptions | fl


Ports
SMTP 25 / 587
POP3 110 / 995
IMAP 143 / 993
EdgeSync 50636


Recovery
Setup.com /M:RecoverServer

http://technet.microsoft.com/en-us/library/dd876954.aspx
New-MailboxDatabase -Recovery -Name RDB1 -Server MBX2
Mount-Database -Identity RDB1
Restore-Mailbox -Identity Scott -RecoveryDatabase RDB1
Restore-Mailbox -Identity Scott -RecoveryDatabase RDB1 -RecoveryMailbox John -TargetFolder Recovery

Export-Mailbox -Identity john@contoso.com -TargetMailbox ExportMailbox -TargetFolder MyData
Export-Mailbox -Identity john@contoso.com -PSTFolderPath C:\PSTFiles\john.pst

Exchange Certificate
Get-ExchangeCertificate
New-ExchangeCertificate -GenerateRequest -SubjectName "C=CH, S=BE, L=Bern, O=Icewolf, OU=IT, CN=mail.icewolf.ch" -DomainName icesrv03, icesrv03.corp.icewolf.ch, mail.icewolf.ch, autodiscover.icewolf.ch, autodiscover.serveralive.ch -PrivateKeyExportable $true
Enable-ExchangeCertificate -Thumbprint <thumbprint> -Services IMAP,POP,IIS,SMTP


Public URL
Enable-OutlookAnywhere -Server NORTHWIND01 -ExternalHostname "mail.northwind.com" -DefaultAuthenticationMethod "Basic" -SSLOffloading:$False
Set-OABVirtualDirectory -identity "NORTHWIND01\OAB (Default Web Site)" -externalurl https://mail.northwind.com/OAB -RequireSSL:$true
Set-WebServicesVirtualDirectory -identity "NORTHWIND01\EWS (Default Web Site)" -externalurl https://mail.northwind.com/EWS/Exchange.asmx -BasicAuthentication:$True
Set-OwaVirtualDirectory -identity "NORTHWIND01\owa (Default Web Site)" -externalurl https://mail.northwind.com/owa
Set-ActiveSyncVirtualDirectory -identity "NORTHWIND01\Microsoft-Server-ActiveSync (Default Web Site)" -externalurl https://mail.northwind.com/Microsoft-Server-ActiveSync


Test
Test-Mailflow
Test-OutlookConnectivity
Test-WebServicesConnectivity
Test-ActiveSyncConnectivity
Test-PopConnectivity
Test-IMAPConnectivity
Test-EcpConnectivity
Test-PowerShellConnectivity

Exchange Remote Connectivity Analyzer
https://www.testexchangeconnectivity.com/


Address List
http://technet.microsoft.com/en-us/library/aa997686.aspx
New-AddressList -Name MyAddressList -RecipientFilter {((RecipientType -eq 'UserMailbox') -and ((StateOrProvince -eq 'Washington') -or (StateOrProvince -eq 'Oregon')))}

Servers
Get-ExchangeServer


Connectors
New-SendConnector -Name SendConnector -AddressSpaces contoso.com
New-SendConnector -Name 'public.com' -Usage 'Custom' -AddressSpaces 'SMTP:public.com;1' -IsScopedConnector $false -DNSRoutingEnabled $false -SmartHosts '[172.21.175.90]' -SmartHostAuthMechanism 'None' -UseExternalDNSServersEnabled $false -SourceTransportServers 'DESTINATION01'
Set-ReceiveConnector -Identity ReceiveConnector -MaxMessageSize 20MB

Set-SendConnector -Identity {identity} -ProtocolLoggingLevel VERBOSE
%ExchangeInstallPath%\TransportRoles\Logs\ProtocolLog\SmtpReceive
%ExchangeInstallPath%\TransportRoles\Logs\ProtocolLog\SmtpSend


Mailbox Database
New-MailboxDatabase -Name MDB01 -EdbFilePath D:\ExchangeDB\MDB01\MDB01.edb -LogFolderPath D:\ExchangeDB\MDB01\ -Server Exchange01
Mount-Database -Identity MDB01
Move-DatabasePath -Identity MDB01 -EdbFilePath C:\NewFolder\MDB01.edb
Remove-MailboxDatabase -Identity OldMailboxDatabase

Get-MailboxDatabase
Get-Mailbox -Server Exchange01 | New-Moverequest -TargetDatabase MDB01
Get-Mailbox -Server Exchange01 -Arbitration | New-Moverequest -TargetDatabase MDB01

CORP.icewolf.ch\Microsoft Exchange System Objects\SystemMailbox{A89BCF10-3F08-41C2-AC86-68E35C08D972}
Get-Mailbox -Arbitration | Remove-Mailbox -Arbitration -RemoveLastArbitrationMailboxAllowed

New-Mailbox -Arbitration -Name "SystemMailbox{A89BCF10-3F08-41C2-AC86-68E35C08D972}" -UserPrincipalName "SystemMailbox{A89BCF10-3F08-41C2-AC86-68E35C08D972}@icewolf.ch"
New-Mailbox -Arbitration -Name "SystemMailbox{e0e13cb6-bd1c-4a67-b483-3fe8db9d3631}" -UserPrincipalName "SystemMailbox{e0e13cb6-bd1c-4a67-b483-3fe8db9d3631}@icewolf.ch"
New-Mailbox -Arbitration -Name "FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042" -UserPrincipalName
FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042@icewolf.ch

Set-MailboxDatabase <database name> -IsExcludedFromProvisioning $True
Set-MailboxDatabase <database name> -IsSuspendedFromProvisioning $True

User Mailbox
Get-Mailbox -identity Ayla@contoso.com
Get-Mailbox -arbitration (3 Systemmailboxes -> must be moved if you want to delete 1st DB)

New-Mailbox -Alias chris -Name "Chris Ashton" -FirstName Chris -LastName Ashton -DisplayName "Chris Ashton" -UserPrincipalName ChrisAshton@contoso.com -OrganizationalUnit Users


Get-MoveRequest
Get-Moverequest -MoveStatus completed | Remove-MoveRequest
Remove-MailboxDatabase -Identity "Old Mailbox Database"

http://technet.microsoft.com/en-us/library/dd298174.aspx
New-MoveRequest -Identity Ayla@contoso.com -TargetDatabase "DB02"

DAG

Get-DatabaseAvailabilityGroup
Set-MailboxDatabaseCopy -Identity [ID] -ReplayLagTime D:H:M:S


New-DatabaseAvailabilityGroup -Name 'DAG1' -WitnessServer 'DESTINATION01' -WitnessDirectory 'D:\fsw'
Remove-DatabaseAvailabilityGroup -Name 'DAG1'

Add-DatabaseAvailabilityGroupServer -Identity 'DAG1' -MailboxServer 'EX01'
Add-DatabaseAvailabilityGroupServer -Identity 'DAG1' -MailboxServer 'EX01'
Remove-DatabaseAvailabilityGroupServer -Identity 'DAG1' -MailboxServer 'EX01'
Remove-DatabaseAvailabilityGroupServer -Identity 'DAG1' -MailboxServer 'EX02'

Add-MailboxDatabaseCopy -Identity 'MDB03' -MailboxServer 'EX02'
Get-MailboxDatabaseCopyStatus -Identity MDB03
Move-ActiveMailboxDatabase -Identity MDB03 -ActivateOnServer EX02

Test-ReplicationHealth
Suspend-MailboxDatabaseCopy -Identity MDB03\EX01
Resume-MailboxDatabaseCopy -Identity MDB03\EX01
Update-MailboxDatabaseCopy -Identity MDB03\EX01
Remove-MailboxdatabaseCopy -Identity MDB03\EX02

 


Permissions
Add-MailboxPermission -AccessRights FullAccess -Identity "Car 54" -User Tony@contoso.com
Remove-MailboxPermission -AccessRights FullAccess -Identity "Car 54" -User Tony@contoso.com
Add-ADPermission "John Simpson" -User "Domain\User" -Extendedrights "Send As"


Quota
Get-MailboxDatabase | fl *quot*
Set-MailboxDatabase -Identity MDB01 -ProhibitSendQuota "2.5 GB" -ProhibitSendReceiveQuota "2.8 GB"

Get-Mailbox -Identity f.fischer | fl *quot*
Set-Mailbox -Identity a.bohren -ProhibitSendReceiveQuota "8 GB" -ProhibitSendQuota "7.5 GB" -IssueWarningQuota "7.3 GB" -UseDatabaseQuotaDefaults $false

Set-Mailbox -Identity "Chris Ashton" -ArchiveQuota 7GB -ArchiveWarningQuota 6.5GB


Create Test Users
10..30 | ForEach { Net User "User$_" MyPassword=01 /ADD /Domain; Enable-Mailbox "User$_" }


Import Users
Name;FirstName;LastName;UPN;OU
Albert Einstein;Albert;Einstein;a.einstein@foo.com;TestOU
Niels Bohr;Niels;Bohr;n.bohr@foo.com;TestOU

$Pwd = ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force
$csv = Import-Csv c:\mitarbeiter.csv
$csv | ForEach-Object{New-Mailbox -Name $_."Name" -FirstName $_."FirstName" -Lastname $_."LastName" -UserPrincipalName $_."UPN" -OrganizationalUnit $_."OU" -Password $Pwd}

 

Export Mailbox
http://technet.microsoft.com/en-us/library/aa998579.aspx
New-ManagementRoleAssignment –Role “Mailbox Import Export” –User “Administrator”
Export-Mailbox -Identity a.bohren -TargetMailbox boa -TargetFolder "a.bohren" -StartDate "MM/DD/YYYY"


Contacts
New-MailContact -Name "Chris Ashton" -ExternalEmailAddress "Chris@tailspintoys.com" -OrganizationalUnit "Marketing"

Mail Enabled User
$password = Read-Host "Enter password" -AsSecureString
New-MailUser -Name "Ed Meadows" -Password $password -ExternalEmailAddress ed@tailspintoys.com -UserPrincipalName ed@contoso.com -OrganizationalUnit contoso.com


Group
New-DistributionGroup -Name "Managers" -OrganizationalUnit "contoso.com/Users" -SamAccountName "Managers" -Type "Security"
Set-DistributionGroup -Identity "Accounting" -DisplayName "Accounting Group"

New-DynamicDistributionGroup -Name "Marketing Group" -Alias "Marketing_Group" -IncludedRecipients "MailboxUsers,MailContacts" -OrganizationalUnit "Contoso.com/Users" -ConditionalDepartment "Marketing","Sales" -RecipientContainer "Contoso.com"


Statistics
Get-MailboxStatistics
Get-MailboxFolderStatistics
Get-Mailbox | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,TotalItemSize,ItemCount
Get-Mailbox | Where {$_.ArchiveGuid -ne "00000000-0000-0000-0000-000000000000"} | Get-MailboxStatistics -archive | Sort-Object TotalItemSize -Descending | ft DisplayName,TotalItemSize,ItemCount


Archive
http://technet.microsoft.com/en-us/library/dd979800.aspx
Set-Mailbox "Tony Smith" -Archive
Get-Mailbox -Database DB01 | Set-Mailbox -Archive
Set-Mailbox -Identity "Chris Ashton" -ArchiveQuota 1GB -ArchiveWarningQuota 950MB

Retention
Understand Retention Tags & Policy http://technet.microsoft.com/en-us/library/dd297955.aspx
http://technet.microsoft.com/en-us/library/dd335226.aspx
--> you cannot mix Retention Policy’s and Managed Folder Mailbox Policy’s.
New-RetentionPolicyTag "RetentionDeletedItems" -Type DeletedItems -RetentionEnabled $true -AgeLimitForRetention 30 -RetentionAction [MarkAsPastRetentionLimit/MoveToDeletedItems/DeleteAndAllowRecovery/PermanentlyDelete/MoveToArchive]
Set-Mailbox -Identity boa -RetentionPolicy "RetentionDeletedItems"

New-RetentionPolicyTag "Retention90Days" -Type All -RetentionEnabled $true -AgeLimitForRetention 90 -RetentionAction MoveToArchive
New-RetentionPolicy "Icewolf Retention Policy" -RetentionPolicyTagLinks "Retention90Days,RetentionDeletedItems"
Set-Mailbox -Identity boa -RetentionPolicy "Icewolf Retention Policy"
Get-Mailbox -Identity boa | fl *retention*
Start-ManagedFolderAssistant

Set-MailboxServer -Identity MyMailboxServer -ManagedFolderAssistantSchedule "Sun.14:00-Sun.13:00"

Get-RetentionPolicyTag | fl name,MessageClass,RetentionEnabled,RetentionAction,AgeLimitForRetention
Get-RetentionPolicy | fl name,RetentionPolicyTagLinks

 

Managed Folders
Requires Enterprise CAL http://technet.microsoft.com/en-us/library/ee364744.aspx

new-ManagedFolderMailboxPolicy -Name 'DeletedItemsPolicy' -ManagedFolderLinks 'Deleted Items'

New-ManagedFolderMailboxPolicy -Name "MyManagedFolderMailboxPolicy" -ManagedFolderLinks Inbox, 'Business Critical'
Set-Mailbox -Identity Chris -ManagedFolderMailboxPolicy "Corp-VPs Managed Folder Mailbox Policy"
Set-MailboxServer -Identity MyMailboxServer -ManagedFolderAssistantSchedule "Sun.14:00-Sun.13:00"
Start-ManagedFolderAssistant


Calendar Repair Assistant
http://technet.microsoft.com/en-us/library/ee633480.aspx
Set-Mailbox -Identity tony@contoso.com -CalendarRepairDisabled $true
Set-MailboxServer -Identity MBX02 -CalendarRepairIntervalEndWindow 90
Set-MailboxServer -Identity MBX02 -CalendarRepairSchedule "Monday.1:00 AM-Monday.4:00 AM","Wednesday.1:00 AM-Wednesday.4:00 AM
Set-MailboxServer -Identity MBX02 -CalendarRepairMissingItemFixDisabled $true


Room
New-Mailbox -Name "SitzungszimmerMoench" -UserPrincipalName "SitzungszimmerMoench@corp.icewolf.ch" -Alias "SitzungszimmerMoench" -LastName "SitzungszimmerMoench" -Room

New-DistributionGroup -Name "Bern Rooms" -RoomList
Add-DistributionGroupMember -Identity "Bern Rooms" -Member Sitzungszimmer
Add-DistributionGroupMember -Identity "Bern Rooms" -Member SitzungszimmerEiger
Add-DistributionGroupMember -Identity "Bern Rooms" -Member SitzungszimmerMoench

ResouceBooking Attendant
Set-CalendarProcessing "SitzungszimmerMoench" -AutomateProcessing AutoAccept -AllowConflicts $false

Set-MailboxCalendarConfiguration
AllowConflicts
BookingWindowInDays
EnforceSchedulingHorizon
MaximumDurationInMinutes
AllowRecurringMeetings
ScheduleOnlyDuringWorkingHours
ConflictPercentageAllowed
MaximumConflictInstances


MailTip
http://technet.microsoft.com/en-us/library/dd335095.aspx

Mailbox
MailContact
MailUser
DistributionGroup
DynamicDistributionGroup
MailPublicFolder


Set-OrganizationConfig -MailTipsAllTipsEnabled $true
Set-OrganizationConfig -MailTipsLargeAudienceThreshold 50 (25 by default)
Set-OrganizationConfig -MailTipsExternalRecipientsTipsEnabled $true
Set-OrganizationConfig -MailTipsMailboxSourcedTipsEnabled $true (Out of Office / Mailbox Full [Default ON])

Set-MailboxServer MBX1 -GroupMetricsGenerationEnabled $true
Set-MailboxServer MBX1 -GroupMetricsGenerationTime 23:30


Set-DistributionGroup -Identity "HR" -MailTip "This distribution group is used for Human Resources departmental communications. If you want to contact an HR representative, please e-mail HRQuestions@contoso.com."


Set-Mailbox -Identity Notifications@contoso.com -MailTip "This mailbox is not monitored."
$Temp = Get-Mailbox Notifications@contoso.com
$Temp.MailTipTranslations += "ES:Esta caja no se supervisa."
Set-Mailbox -Identity Notifications@contoso.com -MailTipTranslations $Temp.MailTipTranslations


Audit
http://www.howexchangeworks.com/2010/02/administrator-audit-logging-in-exchange.html
Run Get-AdminAuditLogConfig | fl to confirm
Set-AdminAuditLogConfig –AdminAuditLogEnabled $true
Set-AdminAuditLogConfig –AdminAuditlogMailbox “AuditMailbox@Hew10.local”
Set-AdminAuditLogConfig –AdminAuditLogCmdlets *mailbox*, *transport*
Set-AdminAuditLogConfig –AdminAuditLogParameters database, server


RBAC
Get-RoleGroup | fl Name,RoleAssignments

Hygiene Management
Delegated Setup
Server Management
Discovery Management
Records Management
Organization Management
Public Folder Management
Recipient Management
View-Only Organization Management
UM Management
Help Desk

Get-RoleGroupMember -Identity "Organization Management"


Multi Mailbox Search
http://technet.microsoft.com/en-us/library/dd298021.aspx
Add-RoleGroupMember -Identity "Discovery Management" -member Administrator
Get-RoleGroupMember -Identity "Discovery Management"

New-Mailbox SearchResults -Discovery -UserPrincipalName SearchResults@icewolf.ch
Get-Mailbox -Resultsize unlimited -Filter {RecipientTypeDetails -eq "DiscoveryMailbox"}
Add-MailboxPermission -Identity "SearchResults" -User "Trusted User" -AccessRights FullAccess


EXPR Outlook Provider
http://technet.microsoft.com/en-us/library/bb123683.aspx
Set-OutlookProvider EXPR -OutlookProviderFlags:ServerExclusiveConnect
Set-OutlookProvider EXPR -OutlookProviderFlags:None (Default)

Performance
http://blogs.technet.com/mikelag/archive/2008/05/02/perfwiz-replacement-for-exchange-2007.aspx
http://msexchangeteam.com/archive/2010/02/03/453931.aspx


Transport Rule
Get-TransportRule -Identity RuleName | Format-List
New-TransportRule -Name "RuleName" -FromMemberOf "Executives" -SentTo "AllCompany" -ApplyClassification "ExecutiveCommunication"
Remove-TransportRule -Identity RuleName


Queue
Get-Queue
Suspend-Queue -Identity Server\Queue
Resume-Queue -Identity Server\Queue
Get-Queue -Identity ICESRV03\Shadow\390 | Get-Message
Get-Message -Identity Server\Queue\Message
Retry-Queue -Identity {Identity}
Remove-Message -Identity <MessageIdentity>


Message Tracking
Get-MessageTrackingLog -Start "03/13/2010 9:00AM" -End "03/15/2010 5:00PM" -Sender "john@contoso.com"


Unified Messaging
Get-UMMailbox -Identity user1 | Format-List
Enable-UMMailbox -Identity tonysmith@contoso.com -UMMailboxPolicy MyUMMailboxPolicy -Extensions 51234 -PIN 5643892 -NotifyEmail administrator@contoso.com -PINExpired $true


Federation
http://technet.microsoft.com/en-us/library/dd351109.aspx
Federation Sharing (txt Record / Autodiscover)
Get-ExchangeCertificate
New-FederationTrust -Name "My Federation Trust" -thumbprint 6C8AABD537D53A78CB84E7EEBC8D759C96283ED3
DNSCmd NS1 /RecordAdd contoso.com "@" TXT "AppID=000000004001A66A"
Add-FederatedDomain contoso.co.uk

Sharing Policy
http://technet.microsoft.com/en-us/library/dd351033.aspx
New-SharingPolicy -Name "Contoso" -Domains contoso.com: CalendarSharingFreeBusyDetail, ContactsSharing


Message Classification
http://technet.microsoft.com/en-us/library/bb123498.aspx  

Grüsse
Andres Bohren