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:
To 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:
- Can accept Values
- Cannot Accept Values (These are predefined parameters)
Get-Mailbox –Identity email@example.com
In the above example, “Get-Mailbox” is a cmdlet, “–Identity” is the parameter & “firstname.lastname@example.org” 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 email@example.com.
Search-Mailbox –Identity firstname.lastname@example.org –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 –email@example.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.
- Get-Command, Get-Command *Set*
- Get-Help <cmdlet> Eg Get-Help Get-MailboxStatistics
- Get-Help <cmdlet> -Detailed Eg Get-Help Get-MailboxStatistics –Detailed
- Get-Help <cmdlet> -Full Eg Get-Help Get-CASMailbox –Full
- 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.
Hope 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.
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