Kategoriarkiv: Exchange

Microsoft Exchange Server

Automagisk dokumentation av Exchange 2013 med PowerShell

Det kan f*n inte finnas nåt tråkigare än att dokumentera inställningar för hand, däremot är det riktigt kul att skriva PowerShell skript 🙂

Utöver att du slipper dokumentera för hand, så får du kvalitet på dokumentationen, samt att du givetvis schemalägger skriptet så att du varje månad skapar en ny, tänk vad skönt att kunna följa historik på förändringar!

Skriptet är skrivet för mindre miljöer med en Exchange Site, så den dokumenterar ALLA servrar som finns, har du många siter så kan du ändra get satserna så att de bara hämtar servrarna från din lokala site.

### Exchange 2013 dokumentation script
# 2014-06-03 Harri Förberg http://itharri.com
#
### Start document and set time and date

$Time = (Get-Date -Format yyyy-MM-dd)
Write-Output ”Created Date $Time” | Out-File C:\Script\ExDoc_$Time.txt
Write-Output ” ” | Out-File C:\Script\ExDoc_$Time.txt -Append

# Get Server list
Write-Output ”*** Servers ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-ExchangeServer | FT -AutoSize NAME, ServerRole, Edition, AdminDisplayVersion) | Out-File C:\Script\ExDoc_$Time.txt -Append

# Database information
Write-Output ”*** Databases ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
$dbs = Get-MailboxDatabase -Status
foreach ($db in $dbs)
{
Write-Output (($db.Name) + (” Size ” ) + ($db.DatabaseSize ) + (” Free Space in DB ”) + ($db.AvailableNewMailboxSpace)) | Out-File C:\Script\ExDoc_$Time.txt -Append
}
Write-Output (Get-MailboxDatabase | FT Name, ServerName, EdbFilePath, LogFolderPath, IssueWarningQuota, ProhibitSendQuota, ProhibitSendReceiveQuota, DeletedItemRetention, MailboxRetention, IndexEnabled, CircularLoggingEnabled, WhenChanged -AutoSize) | Out-File C:\Script\ExDoc_$Time.txt -Append

# Count mailboxes per DB
Write-Output ”*** Mailbox statistics ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
$collection = (Get-MailboxDatabase).Name
foreach ($item in $collection)
{
$Count = (get-mailbox -Database $item -ResultSize Unlimited).count
Write-Output ”mailboxes in $item = $Count ” | Out-File C:\Script\ExDoc_$Time.txt -Append
}
Write-Output ((”Totalt nr of mailboxes = ”) + ((get-mailbox -ResultSize Unlimited).count)) | Out-File C:\Script\ExDoc_$Time.txt -Append

# Mobile Devices
Write-Output ”*** ActiveSync Device AccessRules ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-ActiveSyncDeviceAccessRule | FT Name, Identity, QueryString, Characteristic, AccessLevel, IsValid, WhenChanged -AutoSize) | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ”*** ActiveSync User Statistics ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ((Get-CASMailbox -OrganizationalUnit ”OU=Accounts,OU=Data,DC=sbgstad,DC=se” –ResultSize Unlimited -Filter {HasActiveSyncDevicePartnership -eq $True}).PrimarySmtpAddress | ForEach {Get-MobileDeviceStatistics -Mailbox $_} | Group DeviceModel | Sort Count -Descending | FT Count, Name -AutoSize) | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ”See http://www.enterpriseios.com/wiki/Complete_List_of_iOS_User_Agent_Strings for User Agent Details on IOS Devices” | Out-File C:\Script\ExDoc_$Time.txt -Append

# Public Folders
Write-Output ”*** Public Folders ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-Mailbox -PublicFolder | FT Name, ServerName, RetainDeletedItemsFor, IssueWarningQuota, ProhibitSendQuota, ProhibitSendReceiveQuota -AutoSize) | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ”*** Public Folder Statistik ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
$PFStat = ((Get-PublicFolder \ -Recurse).Count)
Write-Output ”$PFStat Publicfolders in Org” | Out-File C:\Script\ExDoc_$Time.txt -Append

# Get DAG
Write-Output ”*** DAG ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-DatabaseAvailabilityGroup | fl Name, Servers, WitnessServer, WitnessDirectory, DatabaseAvailabilityGroupIpAddresses) | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-MailboxServer | ft Name, DatabaseAvailabilityGroup, AutoDatabaseMountDial, DatabaseCopyAutoActivationPolicy) | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-MailboxDatabaseCopyStatus) | Out-File C:\Script\ExDoc_$Time.txt -Append

# Exchange Connectors
Write-Output ” ” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ”*** Send Connectors ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-SendConnector | FT Name, Comment, AddressSpaces, MaxMessageSize, Port, SmartHostsString, SourceTransportServers, ProtocolLoggingLevel -AutoSize) | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ” ” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ”*** Receive Connectors ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-ReceiveConnector | FT Name, TransportRole, Fqdn, MaxRecipientsPerMessage, MaxMessageSize, Banner, PermissionGroups, ProtocolLoggingLevel -AutoSize) | Out-File C:\Script\ExDoc_$Time.txt -Append

# Offline Addressbook
Write-Output ”*** Offline Addressbooks ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-OfflineAddressBook | FT Name, Versions, AddressLists, WebDistributionEnabled, LastTouchedTime, VirtualDirectories -AutoSize) | Out-File C:\Script\ExDoc_$Time.txt -Append

# Get IIS Directories
Write-Output ”***OWA Virtual Directories ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-OwaVirtualDirectory | FL Identity, OwaVersion, InternalAuthenticationMethods, ExternalAuthenticationMethods, BasicAuthentication, WindowsAuthentication, DigestAuthentication, FormsAuthentication, OAuthAuthentication, AdfsAuthentication, DefaultDomain, InternalUrl, ExternalUrl, WhenChanged) | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ”***ECP Virtual Directories ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-EcpVirtualDirectory | FL Identity, InternalAuthenticationMethods, ExternalAuthenticationMethods, BasicAuthentication, WindowsAuthentication, DigestAuthentication, FormsAuthentication, OAuthAuthentication, AdfsAuthentication, DefaultDomain, InternalUrl, ExternalUrl, WhenChanged) | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ”***EWS Virtual Directories ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-WebServicesVirtualDirectory | FL Identity, InternalAuthenticationMethods, ExternalAuthenticationMethods, BasicAuthentication, WindowsAuthentication, DigestAuthentication, OAuthAuthentication, AdfsAuthentication, InternalUrl, ExternalUrl, WhenChanged) | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ”***EAS Virtual Directories ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-ActiveSyncVirtualDirectory | FL Identity, InternalAuthenticationMethods, ExternalAuthenticationMethods, BasicAuthEnabled, WindowsAuthEnabled, CompressionEnabled, ClientCertAuth, InternalUrl, ExternalUrl, WhenChanged) | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ”***OAB Virtual Directories ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-OabVirtualDirectory | FL Identity, InternalAuthenticationMethods, ExternalAuthenticationMethods, BasicAuthentication, WindowsAuthentication, InternalUrl, ExternalUrl, WhenChanged) | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ”*** Autodiscover Directories ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-AutodiscoverVirtualDirectory | FL Identity, InternalAuthenticationMethods, ExternalAuthenticationMethods, BasicAuthentication, WindowsAuthentication, DigestAuthentication, OAuthAuthentication, AdfsAuthentication, WhenChanged) | Out-File C:\Script\ExDoc_$Time.txt -Append

# Get Client Access Server & Outlook Anywhere Config
Write-Output ”*** ClientAccessServer Config ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-ClientAccessServer | fl Name, OutlookAnywhereEnabled, AutoDiscoverServiceInternalUri, WhenChanged) | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ”*** Outlook Anywhere Config ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-OutlookAnywhere | fl Server, Identity, ExternalHostname, InternalHostname, SSLOffloading, IISAuthenticationMethods, ExternalClientsRequireSsl, InternalClientsRequireSsl, WhenChanged) | Out-File C:\Script\ExDoc_$Time.txt -Append

# Get Exchange Certificates
Write-Output ” ” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ”*** Exchange Certificates ***” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output ” ” | Out-File C:\Script\ExDoc_$Time.txt -Append
$cert = (Get-ExchangeServer).Name
foreach ($item in $cert)
{
Write-Output ”$item” | Out-File C:\Script\ExDoc_$Time.txt -Append
Write-Output (Get-ExchangeCertificate -Server $item) | FT Subject, Issuer, NotBefore, NotAfter | Out-File C:\Script\ExDoc_$Time.txt -Append
}

Exchange 2013 uppdraget jag gjorde har släppts som pressrelease

Kul Exchange 2013 uppdrag, genomfördes direkt efter CU1 släpptes! Extra roligt var att jag fick chansen att genomföra en massa PowerShell automation, till exempel när Skolelever ska läggas till, eller vad sägs om en helt PowerShell baserad dokumentation som dessutom uppdaterar sig själv en gång i månaden, smidigt om man vill backa några månader och se om nåt har förändrats i miljön 🙂

http://www.petri.co.il/windows-server-2012-r2-hyper-v-performance-tips.htm

En utmärkt artikel för att prestanda optimera dina Hyper-V hostar. Rekommenderas varmt.

Exchange 2013 CU 3 släppt

Dags att uppdatera våra Exchange 2013 servrar igen.

Exchange 2013 RCP Client Access service startar om

Det finns ett par olika lösningar, jag föreslår att du testar i ordningsföljd och väntar in resultatet av varje steg innan du går vidare.

1. Öka Connection timeout i registret

HKEY_LOCAL_MACHINE/Software/Policies/Microsoft/Windows NT/
Lägg till Dword: MinimumConnectionTimeout
Lägg till Decimalvärde: 120

2. Ändra konto på RPC Client Access tjänsten från “system account” till “Netwotk Service” account.

3. Stäng av Exchange Health Service tjänsten

 

 

 

 

 

Ännu en dålig patch från Microsoft, Exchange 2013 KB2874216

Inatt togs patchen bort från Microsoft Update. Exchange teamet har släppt följande blogpost om vilka åtgärder som nu måste tas för att fixa problemen som drabbar sökmotorn i Exchange.

Det finns nu en KB artikel som beskriver hur du skall lösa problemen som patchen orsakar. Lustigt nog har Microsoft INTE testat denna patch innan i sin ”Dogfood miljö” innan dom släppte patchen…

Exchange 2013 slutar ta emot SMTP var 4-8 timme

Många är det som har upplevt att Exchange 2013 är ostabilt när det gäller SMTP. Två möjliga lösningar utöver det jag skrev i artikeln tidigare i veckan.

1. Anti-Malware Scanning

Stäng av Anti-Malware Scanning i Exchange 2013 med PowerShell Kommandot, det har rapporterats om timeouts i tjänsten som sedan hänger/låser/stoppar Transport tjänsten

&$env:ExchangeInstallPath\Scripts\Disable-Antimalwarescanning.ps1

2. Gör om din egenskapade connectors så att de ligger på Frontend Transport (inte Hub Transport)

Se en av många trådar i ämnet: http://social.technet.microsoft.com/Forums/exchange/en-US/cd03793b-9e99-474e-8f25-11275652882f/exchange-2013-stops-receiving-external-email-after-about-8-hours

Ett skript som underlättar ifall du har många IP satta i din Receive Connector.

 # Del ett importerar dina gamla Remote IP Ranges
(Get-ReceiveConnector ”ExSrv2013namn\Din Gamla Connector”).RemoteIPRanges | select Lowerbound,Upperbound,RangeFormat | sort-object Lowerbound | export-csvc:\rcip.txt –NoTypeInformation

# Nu behöver du radera din gamla connector och skapa din nya (blir konflikt annars) Kopiera alla inställningar.

# Del två importerar adresserna till nya Connectorn som du precis skapat. 

$csv = ”c:\rcip.txt”
$rc=”ExSrv2013namn\Din Nya Connector”
$impcsv = import-csv $csv
foreach($linein$impcsv)
{
$ipAdd=$line.LowerBound
$conn=Get-ReceiveConnector$rc
$conn.RemoteIPRanges +=$ipAdd
Set-ReceiveConnector$rc-RemoteIPRanges$Conn.RemoteIPRanges
}

 

Exchange 2013 RCP Client Access Service krachar

Har felsökt och konstaterat vissa problem med Exchange 2013 med RPC Client Access service hos kund.

Loggboken visar följande: Först 7031, sedan 7032 och till slut flera 7011 och 5011.

7031:
The Microsoft Exchange RPC Client Access service terminated unexpectedly. It has done this 1 time(s). The following corrective action will be taken in 5000 milliseconds: Restart the service.

7032:
The Service Control Manager tried to take a corrective action (Restart the service) after the unexpected termination of the Microsoft Exchange RPC Client Access service, but this action failed with the following error:

An instance of the service is already running.

7011
a timeout (30000 milliseconds) was reached while waiting for a transaction response from the MSExchangeRPC service.

5011
A process serving application pool ‘MSExchangeRpcProxyAppPool’ suffered a fatal communication error with the Windows Process Activation Service. The process id was ‘21368’. The data field contains the error number.

Drabbade Exchange 2013 servrar kör CU1 samt CU2.

Flera olika lösningar på problemet.
1. I registret, under HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows NT\ lägg till DWORD ”MinimumConnectionTimeout” med Decimalvärde ”120”
2. Stäng av och ”disabla” Exchange Health Services tjänsten.
3. För virtuella maskiner: Öka CPU & Minne
4. Om du stängt av IPv6 slå omedelbart på den igen! (skall aldrig stängas av)

Exchange deployment Assistant uppdaterad

Nu finns äntligen stöd för alla som håller på och migrerar från Exchange 2007 & 2010 till Exchange 2013.

http://blogs.technet.com/b/exchange/archive/2013/04/22/updated-exchange-server-2013-deployment-assistant.aspx

Ladda PowerShell ISE kommandon automatiskt

Jag föredrar PowerShell ISE över ”Old fashion” PS konsolen vilken dag som helst. Dock laddar den inte Exchange, VMM m.m. modulerna automatiskt åt mig.

För att råda bot på detta så kan vi skapa en profil för ISE. Du gör detta genom att skapa en profile.ps1 fil som du sparar i dina dokument under WindowspowerShell mappen.

När profilen är skapad kommer ISE (och vanliga PS) alltid att utföra det du önskar av den vid uppstart, lite som autoexec.bat i dos en gång i tiden 🙂


Sedan ändrar du filen beroende på vad du vill att den skall starta:

Exempel 1: Exchange 2013

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://cas.domain/PowerShell/ -Authentication Kerberos

Import-PSSession $Session

Exempel 2: Exchange 2010 

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010

Exempel 3: SCVMM 2012

Get-Module -ListAvailable *virtual* | import-module

Skulle du hellre vilja starta modulen från ISE menyn?

$psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add(
”Connect to Exchange”,
    {
$s = New-PSSession -ConfigurationName Microsoft.Exchange `
       -ConnectionUri http://cas.domain.com/PowerShell/ `
-Authentication Kerberos

       Import-PSSession $s
    },
 ”Control+Alt+Z”
)

Detta ger dig följande resultat:


Vill du använda profilerna för alla användare? Inga problem, detta var bara en av de sex profilerna som du kan ställa in i PowerShell. Läs vidare på: Hey, Scripting Guy! Blog