In this article, we are going see some in-depth concepts about Microsoft Exchange PowerShell and Windows PowerShell
Introduction:
Exchange PowerShell, also called Exchange Management Shell, is a by-product of Windows PowerShell. Exchange PowerShell is exclusively developed for performing Exchange oriented tasks and automation. The Advantage here is, in the recent version of Exchange PowerShell i.e. Exchange 2013 and 2016 Active Directory modules are pre-included which helps Exchange Admin to perform additional and useful tasks in Exchange since all the mailboxes are mere objects of Active Directory.
In the following sections, we will use the two terms “Exchange PowerShell” and “Exchange Management Shell” interchangeably.
What is Exchange PowerShell (PS)?
Exchange PS is an interactive command line tool that works based on Object Oriented Programming Concept. Unlike other command line tools in Unix or Linux, the cmdlets are user friendly and easy to understand. PowerShell can acquaint itself to other programming languages such as C, C#, VB.Net etc. This makes programmers and automation developers to create interactive programs and software to create reports and tasks.
It was first introduced along with Exchange 2007, as Microsoft moved on with newer Exchange Systems, they also concentrated on PowerShell and developed it. The latest version is 2016. It basically a backend PS1 script that gets embedded on Windows PowerShell. By default, Exchange PowerShell script files are installed on the below locations:
Exchange 2010:
D:\Program Files\Microsoft\Exchange Server\V14\Bin\RemoteExchange.ps1
How does Exchange PowerShell (PS) works?
Windows PS directly interacts with Windows Management Framework and Windows Management Instrumentation and provides the output, likewise the Exchange PS talks directly to Exchange system. Exchange Management Tools and PowerShell can also be separately installed on a client machine. Supported configuration such as
- Windows Vista 64-bit with SP2
- Windows 7 64-bit and above
- Windows Server 2008 64-bit with Service Pack 2
- Windows Server 2008 R2 and above.
Windows PS got its own EXE file, which will be called upon for every time we open the tool
For Exchange PS, there is no direct EXE file as it is relying on Windows PS. So if you open the Exchange PS, it will actually use powershell.exe and execute the remoteexchange.ps1 script to make it as Exchange PS. If you open the properties, you can see the target as below path.
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -version 2.0 -noexit -command “. ‘C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto”
Below screenshot shows you the properties of Exchange PS and you see the target over there.
In simple terms, the front-end view is provided by Windows PowerShell and the Exchange script files are injected to it.
After you initiate the Exchange PowerShell you can see that it will connect to the nearest Client Access Server (CAS). Even if you initiate the PS inside a CAS server it will create an implicit remote connection with the same server and it will give tips and the verbose will display the Connected Server.
Advantages of Exchange PowerShell:
- It can be used for automating some of the routine tasks and reports.
- Replication is almost instantaneous. We do not need to wait for long as we do while using console.
- Easy obtain information & data that is not available through GUI.
- Importing other modules like active directory etc.,
Understanding Exchange PowerShell Commands:
Commands of Exchange PowerShell in the form of Verb-Noun combination, this makes the cmdlets easily understandable and avoids the necessity to memorize it. For example, Add-FederatedDomain, Get-Mailbox, Set-SiteMailbox. The First word is a Verb which denotes the action that needs to performed and the second word is a Noun which denotes the object on which the action to be performed. As we work more with the commands, we will be able to identify its usage. It strictly follows “Camel Casing” for its cmdlets naming conventions. It means there are no gaps in between the words, and also the First letter of each word should be capitalized.
Conclusion:
There are lot more verbs and nouns available in Exchange PS. We can deep dive into verbs in the later parts. It can be used to recover the data however the easiest option is Exchange OST Recovery, where we do not need to restore from backup and merge which sometime cause duplicate issues if it is not done properly.
Author Introduction:
Sophia Mao is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair pst and word recovery software products. For more information visit www.datanumen.com