In-depth Concepts on Microsoft Exchange PowerShell (Part II)

In the last article, we have seen the introduction of Exchange Power Shell. And in this article we are going to learn how to use it

Get started with Exchange PowerShell:

ExchangeTo write scripts, one should know the related cmdlets and parameters corresponding to their task. As Microsoft keeps introducing new and depreciating some old cmdlets, it is not easy for anyone to know all the cmdlets and parameters. Hence Microsoft has introduced multiple ways to discover the cmdlets for each tasks and help items that can explain in-detail about that cmdlets. Reading those help items will make us to understand whether that can be used in the script which can ultimately satisfies our requirement.

These help items are very detailed and highly specific to each cmdlets. For any person who wish to learn PowerShell, it’s highly recommended to start with understanding on how to search for commands and should learn how to read & understand help statements.

Cmdlets, Parameters, Variables & Property

Cmdlets are the heart and brain of any scripts. The words in the combination of Verb-Noun tags are called as cmdlets (eg) Get-Queue, Get-Mailbox etc., Parameter is a sub property of cmdlet which helps to pass inputs or get outputs from it. These are helper objects, cmdlets can accept single parameter or multi-parameters

Parameters are of two types:

  1. Can accept Values
  2. Cannot Accept Values (These are predefined parameters)

Example 1:

Get-Mailbox –Identity info@datanumen.com

In the above example, “Get-Mailbox” is a cmdlet, “–Identity” is the parameter & “info@datanumen.com” is a value. This cmdlet is of single parameter and that parameter can accept values. This cmdlet would return the basic properties of the mailbox info@datanumen.com.

Example 2:

Search-Mailbox –Identity info@datanumen.com –Archive

In the above example “Search-Mailbox” is a cmdlet “-Identity” is a valued parameter and “-Archive” is a non-valued parameter. This cmdlet instructs PS to Search the archive mailbox of the source –info@datanumen.com

Properties are the outputs given by the cmdlets. Each will have its own properties. A Mailbox might have 100 properties i.e. Mailbox Name, size, database Name, server Name, folders, deleteditemdetails etc. All these properties will not be associated to a single cmdlet. Each one belongs to different cmdlets. For instance Mailbox Name, Database Name, Server Name are associated to “Get-Mailbox”, likewise Folderdetails, deleteditemdetails are associated to “Get-MailboxStatistics”.

Reading Help Statements:

So for a beginner to write advanced tasks like Mailbox recovery or OST file recovery etc., should always know the parameter and properties belongs to a cmdlet. He can use the help statements. The Prime help statements recommended are below.

  1. Get-Command, Get-Command *Set*
  2. Get-Help <cmdlet> Eg Get-Help Get-MailboxStatistics
  3. Get-Help <cmdlet> -Detailed Eg Get-Help Get-MailboxStatistics –Detailed
  4. Get-Help <cmdlet> -Full Eg Get-Help Get-CASMailbox –Full
  5. Get-Help <cmdlet> -Examples Eg Get-Help Get-CASMailbox –Examples

Get-Command: List all the available cmdlets for use

Get-Command *Set*: List all the cmdlets that have the word “Set” in it. It will search both the Verb & Noun

Get-Help Get-MailboxStatistics: Provides the basic information about the cmdlet “Get-MailboxStatistics”

This gives the Synopsis, Syntax and description

Get-Help Get-MailboxStatistics –Detailed: This help statement provides the some more additional information and parameters that can be used along with this cmdlet. Each Parameter will be explained separately with other enriched information.

Get-Help Get-CASMailbox –Full: This help statement provides the complete information with lots of examples. Most admin will prefer this as it will all the required information.

Conclusion:

Exchange PowerShellHope this article would have helped you to understand the concepts of PowerShell. Exchange PowerShell holds complete control in Exchange Management and it makes space for working on certain options that is not available in GUI. Apart from this it is always advisable to ask the internet for anything and it will never leave us unanswered.

Author Introduction:

Sophia Mao is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair pst corruption and word recovery software products. For more information visit www.datanumen.com

Comments are closed.