Thursday 22 November 2012

Exchange Powershell Script

Exchange Control Panel (ECP):
Get-EcpVirtualDirectory | fl *url*, ide*

Set-EcpVirtualDirectory –Identity “TLCAS01\ecp (Default Web Site)” –ExternalUrl https://mail.testlabs.se/ecp

Autodiscover:
Get-ClientAccessServer | fl *uri*

Set-ClientAccessServer –Identity TLCAS01 –AutoDiscoverServiceInternalUri https://autodiscover...utodiscover.xml

Exchange ActiveSync (EAS):
Get-ActiveSyncVirtualDirectory | fl *url*, ide*

Set-ActiveSyncVirtualDirectory –Identity “TLCAS01\Microsoft-Server-ActiveSync (Default Web Site)” –ExternalUrl https://mail.testlab...rver-ActiveSync

Exchange Web Services (EWS):
Get-WebServicesVirtualDirectory | fl *url*, ide*

Set-WebServicesVirtualDirectory –Identity “TLCAS01\EWS (Default Web Site)” –ExternalUrl https://mail.testlab...S/Exchange.asmx

Offline Address Book (OAB):
Get-OabVirtualDirectory | fl *url*, ide*,pol*

Set-OabVirtualDirectory –Identity “TLCAS01\OAB (Default Web Site)” –ExternalUrl https://mail.testlabs.se/OAB –PollInterval 60

Outlook Web App (OWA):
Get-OwaVirtualDirectory | fl *url*, ide*

Set-OwaVirtualDirectory –Identity “TLCAS01\OWA (Default Web Site)” –ExternalUrl https://mail.testlabs.se/OWA

PowerShell:
Get-PowerShellVirtualDirectory | fl *url*, ide*

Set-PowerShellVirtualDirectory –Identity “TLCAS01\PowerShell (Default Web Site)” –ExternalUrl https://mail.testlabs.se/powershell

Enable Outlook Anywhere:

Enable-OutlookAnywhere –Server TLCAS01 –ExternalHostname mail.testlabs.se –InternalHostname tlcas01.testlabs.se –ExternalClientAuthenticationMethod Basic –InternalClientAuthenticationMethod Ntlm –IISAuthentication Ntlm –SSLOffloading:$false
Get-OutlookAnywhere –Server TLCAS01
Get-AcceptedDomain
New-AcceptedDomain –Name testlabs.com –DomainName testlabs.com –DomainType Authoritative
Get-EmailAddressPolicy
Get-EmailAddressPolicy | fl


Send & Receive Connector
Get-ReceiveConnector
Get-ReceiveConnector | fl
Set-ReceiveConnector –Identity “TLCAS01\Default Frontend TLCAS01” –MaxMessageSize 30MB
Get-ReceiveConnector | fl ide*,maxmes*
Get-SendConnector
Get-SendConnector| fl

New-SendConnector –Name “Outbound” –AddressSpaces ‘*’ –SourceTransportServers TLMB01 –MaxMessageSize 30MB

New-SendConnector –Name “Outbound” –AddressSpaces ‘*’ –SourceTransportServers TLMB01 –
MaxMessageSize 30MB –DNSRoutingEnabled:$false –SmartHosts “10.10.10.10”

New-SendConnector –Name “Outbound” –AddressSpaces ‘*’ –SourceTransportServers TLMB01 –
MaxMessageSize 30MB –DNSRoutingEnabled:$false –SmartHosts “10.10.10.10” –FrontEndProxyEnabled:$True

Get-SendConnector| fl ide*,maxmes*

Globaladdresslis
Get-Globaladdresslist | update-Globaladdresslist
Get-Addresslist | Update-Addresslist
New-GlobalAddressList -Name "gal" -RecipientFilter {(MemberOfGroup -eq 'cn=<GROUP NAME>,OU=Exchange Groups,DC=ggncloud,DC=internal')}

Update-GlobalAddressList -Identity "gal"
update-AddressList -Identity '\All Contacts
Move Request
New-MoveRequest -Identity 'tony@alpineskihouse.com' -TargetDatabase DB01 –WhatIf    
New-MoveRequest -Identity 'tony@alpineskihouse.com' -TargetDatabase DB01 -BadItemLimit  100
New-MoveRequest -Identity 'tony@alpineskihouse.com' -TargetDatabase DB01 -BadItemLimit 200 -AcceptLargeDataLoss
New-MoveRequest -Identity 'Kweku' -PrimaryOnly -TargetDatabase "DB01" -BadItemLimit 100 –AcceptLargeDataLoss
Get-MoveRequest –MoveStatus queued |Get-MoveRequestStatistics | ft -auto alias,Status,TotalMailboxSize,PercentComplete,TargetDatabase,TotalInProgressDuration
Suspend-MoveRequest -Identity Shaji_John@abc.com -SuspendComment "Resume suspended request.after @12 PM Today"
Get-MoveRequest -MoveStatus queued | Suspend-MoveRequest -SuspendComment "Resume suspended request.after completion Domino & Cadista"
Get-MoveRequest -MoveStatus suspended | Resume-MoveRequest
Get-LogonStatistics -Database DB-MBX-2
Get-LogonStatistics -Identity shiva_prasad@abc.com
Get-MoveRequest -MoveStatus failed -TargetDatabase DB-mbx1
Get-MoveRequest –MoveStatus Rajesh_Kajalkar@xyz.com
Get-MoveRequest -TargetDatabase DB-MBX-M8 | Suspend-MoveRequest -SuspendComment "Resume @ 12 PM."
Suspend-MoveRequest -TargetDatabase DB-MBX-M8 -SuspendComment "Resume @ 12 PM."
(Get-MoveRequest  –MoveStatus queued).count
(Get-MailboxStatistics -Database DB-MBX-3).Count
Get-Mailbox -Database DB-MBX-G7 | Get-MailboxStatistics | Select-Object DisplayName, ServerName, Database,
TotalItemSize, ItemCount, StorageLimitStatu
 
MailboxStatistics
Get-MailboxStatistics -Server ggncloud | Where {$_.DisconnectDate -ne $null} | Format-Table DisplayName,Database

Get-MailboxStatistics -Server HNLMBX01 | Where {$_.DisconnectDate -ne $null} | Format-Table DisplayName,DisconnectDate
Get-MailboxStatistics -Server HNLMBX01 | Where-Object {$_.DisconnectDate
-gt (Get-Date).AddDays(-7)} | Format-Table displayName,ServerName,
DatabaseName, TotalItemSize -Autosize

Get-MailboxStatistics -Database db3 | where {$_.LastLogonTime -lt
(Get-Date).AddDays(-7)}} | Format-Table displayName,lastlogontime,
lastloggedonuseraccount,ggncloud

Get-MoveRequestStatistics -database db3
Get-Mailbox -Database db3 | New-MoveRequest -TargetDatabase db4
Get-LogonStatistics -Server ggncloud

TransportRule
New-TransportRule -Name 'TS Rule1' -Comments 'transportrule' -Priority '0' -Enabled $true -From 'shailendra@corp.mld' -DeleteMessage $true -ExceptIfFrom 'john@corp.mld'

DatabaseAvailabilityGroup
Restore-DatabaseAvailabilityGroup –Identity DAG1 –ActiveDirectorySite ggncloud
Remove-DatabaseAvailabilityGroupServer -MailboxServer 'RAKESH' -Identity 'DAG2
Get-MailboxDatabase -Status | Sort-Object name | Format-Table Name, DatabaseSize, AvailableNewMailboxSpace
Get-MailboxDatabase -Identity databasename -Status | Format-Table Name, DatabaseSize, AvailableNewMailboxSpace
Get-DatabaseAvailabilityGroupNetwork -Identity DAG2 | fl name, MapiAccessEnabled
Suspend-MailboxDatabaseCopy -Identity DB1\MBX2 -ActivationOnly

Resume-MailboxDatabaseCopy -Identity DB1\MBX2
Set-MailboxServer -Identity MailboxServer–DatabaseCopyAutoActivationPolicy
Set-MailboxServer -Identity MailboxServer–DatabaseCopyAutoActivationPolicy

DynamicDistributionGroup
New-DynamicDistributionGroup -Name "All Research" -IncludedRecipients ‘MailboxUsers’
-ConditionalDepartment ‘Research’ -OrganizationalUnit ‘its’-Alias ‘AllResearch’

new-DynamicDistributionGroup -Name 'DDG-ITS' -RecipientContainer 'corp.mld/ITS' -IncludedRecipients 'AllRecipients' -OrganizationalUnit 'corp.mld/ITS' -Alias 'DDGits'

Set-DynamicDistributionGroup -Name "All Research" -MaxReceiveSize 75KB
New Mailbox


New-Mailbox -Name "System Administrator" -FirstName "System" -LastName "Administrator" -DisplayName "System Administrator" -Alias "sysadmin" -SamAccountName "sysadmin" -organizationalUnit "Test" -Database "MBXDB3" -UserPrincipalName sysadmin@test.com

New-Mailbox -Name:'Help Desk' -OrganizationalUnit:'corp.mld' -Database:'DB01' -UserPrincipalName:'helpdesk@corp.mld' -Shared

Import-CSV "c:\CreateTest.csv" | ForEach-Object { New-Mailbox -Lastname $_.”LastName” -Name $_."DisplayName" -FirstName $_.”FirstName” -Alias $_.”Alias” -SamAccountName $_.”SamAccountName” -organizationalUnit "OU=Test,OU=Departments,DC=test,DC=ac,DC=in" -Database "MBXDB3" -UserPrincipalName $_.”UserPrincipalName” -Password (ConvertTo-SecureString $_.password -AsPlainText -Force)}

FirstNameLastNameDisplayNameAlias SamAccountNamePasswordUserPrincipalName
SystemAdministratorSystem Administratorsysadmin   sysadminnKP5Z6Bzsysadmin@test.com

Tuesday 20 November 2012

Installing the Exchange Server 2013 Preview on Windows Server 2012

In case you haven’t heard, this week Microsoft unveiled preview editions of Exchange 2013, SharePoint 2013, Office 2013, Lync Server 2013, and the new version of Office 365. As you could imagine, there are a slew of new features in each product. From an Exchange point of view, we’re left with only two core server roles; Client Access Server and Mailbox Server. With this new architecture there are some changes to the deployment process. In this post we’ll walk through the installation of the Exchange Server 2013 Preview on Windows Server 2012. Keep in mind that this is preview only, and some of the screens, along with the technical details, are subject to change. The lab environment I’ll be using looks like this:
Active Directory Requirements & Prerequisites
Your Schema Master can still run Windows Server 2003, but your global catalog servers need to be running 2008 or higher. As before, your forest/domain functional levels should be at 2003 or higher. And of course, since this is a new installation of Exchange, the AD schema will need to be extended. For the purposes of this walk-through, this will be done over the wire from the Exchange server during setup. As a prerequisite for this, I’ve installed the RSAT-ADDS tools by issuing the following PowerShell command: Install-WindowsFeature RSAT-ADDS. For more details on the AD requirements, see the Network and directory servers topic under the Exchange 2013 System Requirements in the TechNet documentation.
Server Prerequisites
Two of the main prerequisites are the Windows Management Framework 3.0 (which includes PowerShell v3) and the .NET Framework 4.5. Both of these are already installed on Windows Server 2012.
The remaining operating system prerequisites can be installed by issuing the following command from PowerShell. This will install the OS prerequisites for both the CAS and Mailbox roles:
Install-WindowsFeature AS-HTTP-Activation, Desktop-Experience, NET-Framework-45-Features, RPC-over-HTTP-proxy, RSAT-Clustering, Web-Mgmt-Console, WAS-Process-Model, Web-Asp-Net45, Web-Basic-Auth, Web-Client-Auth, Web-Digest-Auth, Web-Dir-Browsing, Web-Dyn-Compression, Web-Http-Errors, Web-Http-Logging, Web-Http-Redirect, Web-Http-Tracing, Web-ISAPI-Ext, Web-ISAPI-Filter, Web-Lgcy-Mgmt-Console, Web-Metabase, Web-Mgmt-Console, Web-Mgmt-Service, Web-Net-Ext45, Web-Request-Monitor, Web-Server, Web-Stat-Compression, Web-Static-Content, Web-Windows-Auth, Web-WMI, Windows-Identity-Foundation
Unified Communications Managed API 4.0 (Preview) Runtime
After you’ve installed the Desktop Experience feature as part of the previous step and have rebooted your servers, you’ll need to install the Unified Communications Managed API 4.0 runtime. Make sure you install this component on both the CAS and Mailbox servers. Once installed, remove/uninstall the Visual C++ 11 Beta Redistributable (x64) – 11.0.50531 from each server.
Office 2010 FilterFilter Pack
Make sure you install the Office 2010 Filter Pack and the Office 2010 Filter Pack SP1 packages on the Mailbox server.
Installing the prerequisites is much easier on Windows Server 2012. There’s more steps involved in installing it on Windows Server 2008 R2. For full details, see Exchange 2013 Prerequisites on TechNet.
Graphical Install – Mailbox Server Role
The Client Access Server role is truly a front-end/proxy for the backend, which is the Mailbox Server role (sound familiar?). So we’ll start off by installing the back-end first, because with only a front-end, there is nothing to proxy to.
 Initially setup.exe will check for updates
Next we get into the installation. If you’ve done a few Exchange 2010 installations, the options throughout the rest of the wizard will be very familiar.

Accept the License Agreement and click next
Specify your Error Reporting preference and click next

Some prerequisite checks will be performed. If any issues were found (missing prerequisites, etc.) this should let you know
Make you Server Role Selection and click next
Specify an installation path and click next


Since we’re installing into a clean forest, a new organization needs to be created as part of the Active Directory prep


Malware scanning, which is brand new in 2013. I’ve chosen NOT to disable it, so it will be turned on by default. You can read more about this under Anti-Spam and Anti-Malware Protection in the TechNet documentation.


Select an option for the Customer Experience Improvement Program and click next


Some final readiness checks will be made


Depending on the server resources in your lab, this next step can take a bit of time to complete. In my lab, this took at about 15-20 minutes on a VM with 4 vCPUs and 4GB of RAM.



Windows Firewall Configuration – CAS Server
Before installing your CAS, you need to modify the Windows Firewall to allow Exchange to access the registry of the Client Access server. When splitting the servers roles like this (CAS and Mailbox on independent servers) you’ll need to make sure that the Windows Firewall on the CAS server allows TCP port 139 inbound. On the CAS, perform the following steps:
o   Open Control Panel\Windows Firewall
o   Click Advanced Settings
o   Click Inbound Rules
o   Click New Rule…
o   Select Port and then Next
o   Select TCP and in Specify local ports, type 139. Click Next
o   Select Allow this connection and click Next
o   Click Next again to accept the default selections
o   Enter a name and description for the new rule and flick Finish
Command Line Install – CAS Server Role
Command line installations have changed a bit as well. Now that we’ve got the Mailbox Server role installed with the GUI, lets deploy the CAS using a command line installation. To perform the install, use the following command from an elevated prompt:
Setup.exe /mode:Install /role:ClientAccess /IAcceptExchangeServerLicenseTerms


Unlike previous versions of Exchange, setup.com is not used, and we can now use setup.exe to perform the install from the command line. Alot of the previous switches, such as mode, and role, still work, as shown above. The most interesting addition is the /IAcceptExchangeServerLicenseTerms switch which automatically accepts the Exchange 2013 Preview licensing terms. For full details, check out Install Exchange 2013 in Unattended Mode in the TechNet documentation.

Post Installation
After the installation is complete, you can manage Exchange 2013 with the shell, or through the Exchange Administration Center (EAC), which is a new web based management tool. The Exchange Management Console is no longer part of the product in Exchange 2013. To run the EAC, navigate to http://cas_server_name/ecp
                          

   

Many of the configuration screens are very similar to what you would see in EMC. If you’re familiar with Exchange 2010 then you should be able to find your way around in here quite well.
Accessing a Mailbox from Outlook Web App
After the installation is complete, you’ll want to head over to OWA and send yourself an email to make sure your Exchange Server 2013 Preview is fully functional. You’ll still navigate to the CAS for this, e.g. http://cas_server_name/owa













As you can see from the screen shot, OWA has been completely overhauled. The user interface now supports the use of touch screens, enhancing the experience with tablets and smartphones. You can even go “offline” with OWA and access your mail without a connection to the server.
There’s so much more to talk about with Exchange Server 2013. Keep your eye on this blog and follow me on twitter for updates. To get started with Exchange 20103 and build your own lab, head over to the TechNet Evaluation Center and Download the Microsoft Exchange Server 2013 Preview.

Exchange Server 2013

Exchange Server 2013 comes with a number of new features as well as improvements on existing features that are already familiar to those who have worked with Exchange Server 2010.
Here are a few of the highlights:
  • Reduction in server roles to just two; Client Access server and Mailbox server
  • New streamlined Outlook 2013 and Outlook Web App user interfaces, and offline access for OWA
  • No more Exchange Management Console, all administration is now performed using the new web-based Exchange Administration Center and the Exchange Management Shell (using PowerShell 3.0)
  • Improvements to high availability features and manageability
  • Public folders are now stored in mailbox databases and can take advantage of Database Availability Groups for replication and high availability
  • Data loss prevention capabilities that can be integrated into Transport Rules
Getting Started with Exchange Server 2013
The Exchange 2013 Preview has been publicly released so that you can try it yourself. Note that it is not supported to run Exchange Server 2013 Preview in production environments (in fact it currently has no co-existence support with previous versions).
Explore some of the features of Exchange Server 2013:

New Features in Exchange Server 2013

Here's a list from Microsoft of some of the new Exchange Server 2013 features:

Offline support in OWA: Emails and actions are automatically synced the next time connectivity is restored.

Site Mailboxes bring Exchange emails and SharePoint documents together

Outlook Web App offers three different UI layouts optimized for desktop, slate, and phone browsers

Ability to customize Outlook and OWA by integrating apps from the Office marketplace. (Yes, this is a reference to the
Agaves add-ins that Microsoft and partners will be making available via the new Office Store.) The new "Napa" tools and/or HTML5 are Microsoft's preferred ways to developers to build these.

Replacement of the Exchange Management Console by a Web-based Exchange Administrative Center (EAC)
Support for up to 8 TB disks and multiple databases per disk via Data Availability Group (DAG) management

Built in basic anti-malware protection, with ability for administrators to configure and manage settings from inside EAC. (Note: this feature can be turned off, replaced or "paired with premium services such as Exchange Online Protection for layered protection.")

New Data Loss Prevention (DLP) capabilities for identifying and protecting "sensitive data." DLP policies are based on regulatory standards, including PII and PCI. Also: new policy tips in Outlook 2013 can be set to inform users about potential policy violations.

In-Place eDiscovery can be run across Exchange, SharePoint, and Lync from a single interface

Here are
some more new Exchange 2013 features, courtesy of Michael Van Horenbeeck, a member of the Pro-Exchange community and consultant/trainer with Xylos:

A reduction in the number of available roles to two: a Client Access Server and a Mailbox Server role. The result: These two roles are now "loosely coupled," as Microsoft explains it. More from the Softies on this architectural change:
The Mailbox server includes all the traditional server components found in Exchange 2010: the Client Access protocols, Hub Transport service, Mailbox databases, and Unified Messaging. The Mailbox server handles all activity for a given mailbox. The Client Access server provides authentication, redirection, and proxy services. The Client Access server itself doesn't do any data rendering. The Client Access server is a thin and stateless server. There is never anything queued or stored on the Client Access server. The Client Access server offers all the usual client access protocols: HTTP, POP and IMAP, and SMTP."
FAST Search now integrated into Exchange 2013 managed store to provide a more consistent (across Microsoft servers) indexing and searching experience

Inclusion of a "Managed Store," with is the name of the rewritten information store processes, which are now written in C#