A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service
when your organization decides to upgrade to Exchange Server To experience some new features, such as integrated e-mail archiving, discovery capabilities, and highly available features. Whether you like it or not, you should be aware that PowerShell is already part of the Exchange Server Administration tool, and you need to learn some basic scripting knowledge to build some script management Exchange Server. This book is an introduction to this. In this chapter, Some of the core concepts of PowerShell are introduced, which make it easy for you to learn some of the examples mentioned in this book. Of course, if your PowerShell is more familiar, you can skip this chapter or review the basics of PowerShell
PowerShell adopted based on the NET Framework object model, the object's delivery is passed through the pipeline, not plain text. For example, in Exchange , we have access to very detailed information through objects such as mailbox servers, mailboxes, databases, and so on. For example, you use PowerShell to manage each mailbox, which is an object that has many properties, such as e-mail addresses, database locations, send acceptance limits, and so on. So we can build some scripts to get this information and generate reports or help us with routine maintenance work.perform a few basic steps
in The example code in this chapter, start the EMS as follows:
1. log on to a workgroup or server that has Exchange management tools installed
2. If your computer does not have Exchange management tools installed, you can connect through remote PowerShell
$Session = New-pssession-configurationname Microsoft.exchange '
-authentication Kerberos '
3, to open exchange Management Shell , in turn, proceed as follows: Start à Span style= "font-family: ' The song Body '; > All Programs à microsoft Exchange Server windows Server windows key in metro exchange Management Shell Icon
4. Click the icon to open the Exchange Management Shell Command-line administration tool
Note: When we start Exchange Management Shell , remember to run as administrator to avoid some permissions issues causing unnecessary permissions issues
In this chapter, it should be noted that the accent marks are used for line wrapping in the previous example, and this is done to facilitate readingusing the Help system
in the Exchange Server in which Exchange Management Shell over the - command, and each group has a number of parameters. For example:new-mailbox accepts more than one parameter, and set-mailbox is more than the available parameters, so many parameters, we are not possible one by one to remember, so we need to use the Help system.
So, how to use our Help Han system?
get the Help information for a command that we can Exchange Management Shell (hereafter referred to AS EMS console), enter: get-help Cmdletname . For example, to get The Help information for the Get-mailbox command, we can use the following command:
You can also use the following switch parameters to obtain specific information:
Detailed: The Detailed view provides a description and an instance of the parameter, which can be used in the following syntax:
Examples: you can see multiple instances using this command, which can be used as follows:
Full : Use this parameter to view the full contents of the Help file, with the following syntax:
some parameters accept simple strings as input, but there are some that require an actual object. When we create a mailbox using ner-mailbox , we need to provide a secure string object for the password parameter. You can determine the type of this parameter by using the following command:
Get-help New-mailbox–parameter Password
650) this.width=650; "title=" 01.png "style=" height:321px;width:720px; "border=" 0 "hspace=" 0 "alt=" Wkiol1tbdwerisycaaimx64wy8g147.jpg "src=" http://s3.51cto.com/wyfs02/M00/58/ED/ Wkiol1tbdwerisycaaimx64wy8g147.jpg "width=" 720 "height=" 321 "/>
In the output, you can see a few key information in the password parameters, in addition to see -password the required data type is <SecureString> , you can also see that this is a named parameter. A named parameter is a wildcard character that is not accepted when running New-mailbox. You can also use the syntax in this instance to view The parameter settings supported by other cmdlet commands.
You can run get-help new-mailbox–examples See how to create a new mailbox, about new, modify, and delete mailboxes we unify in chapter three to explainmore Command Instances
Perhaps, when you do not know the full name of a command, we can also search by command, for example:
You can also use a -verb Parameter to find all the arguments that begin with this particular verb, for example:
To search for a specific noun, you can specify a noun parameter in the following format:
650) this.width=650; "title=" 02.png "style=" height:167px;width:720px; "border=" 0 "hspace=" 0 "alt=" Wkiom1tbdjcx8hwyaafkqmafdfc938.jpg "src=" http://s3.51cto.com/wyfs02/M00/58/EF/ Wkiom1tbdjcx8hwyaafkqmafdfc938.jpg "width=" 720 "height=" 167 "/>
Other help command formats:
Get-help about_*get help with commands and features
> First, we might be confusing with commands and functions. When you start exchange Management Shell powershell Session was initialized to exchange server and specific commands, this is called the function agent, is imported into the get-mailbox
when you get from Shell Run in Get-mailbox function, the data is PowerShell Session passed between the client machine (the machine running the console) and the server. the get-mailbox command is actually running on a remote Exchange Server, and the results are passed to our console. The advantage is that we can operate the corresponding commands on the remote computer, especially for some cloud servers, which can bring convenience.
Consider the following command and output:
650) this.width=650; "title=" 03.png "style=" height:112px;width:720px; "border=" 0 "hspace=" 0 "alt=" Wkiol1tbdwjsdbtpaacjk8mcc-u984.jpg "src=" http://s3.51cto.com/wyfs02/M01/58/ED/ Wkiol1tbdwjsdbtpaacjk8mcc-u984.jpg "width=" 720 "height=" "/>"
again, we can try. Get-mailbox Command
650) this.width=650; "title=" 04.png "style=" height:124px;width:720px; "border=" 0 "hspace=" 0 "alt=" Wkiom1tbdjczhgelaacgvrqowma139.jpg "src=" http://s3.51cto.com/wyfs02/M01/58/EF/ Wkiom1tbdjczhgelaacgvrqowma139.jpg "width=" 720 "height=" 124 "/>
Here we should be able to see that Get-mailbox a feature is displayed in the command box above. We will be able to command in the subsequent process, for Exchange So many commands, we have to make full use of the Help system, more use of the get-help command, if for some commands can not remember the full name, We can also search the way to find the command first, such as using Get-command , and then use the Help system to find the usageUnderstanding the syntax and parameters of a command
Windows PowerShell provides a number of built-in commands to perform specific operations. the exchange Management Shell has added A single set of commands for Exchange management. We can use these commands to manage Exchange , or we can write some scripts for automated management.
when executing a command, parameters can be used to provide specific information, such as a mailbox or a server, and we can specify which properties to modify. In this section, let's take a look at basic PowerShell syntax and how to use these parameters
when we run a PowerShell command, we enter a command, followed by a number of arguments, preceded by a hyphen ( - ). Let's take a look at some basic examples below. To get a specified user's mailbox information, use the syntax command:
650) this.width=650; "title=" 05.png "style=" Float:none; "alt=" wkiol1tbdwiwohu0aacsdic9hy8122.jpg "src=" http:/ S3.51cto.com/wyfs02/m02/58/ed/wkiol1tbdwiwohu0aacsdic9hy8122.jpg "/>
Alternatively, we can use the following command to output the same result because -identity parameters are positional parameters
650) this.width=650; "title=" 06.png "style=" Float:none; "alt=" wkiom1tbdjgaf1ecaacm9nrgqak076.jpg "src=" http:/ S3.51cto.com/wyfs02/m02/58/ef/wkiom1tbdjgaf1ecaacm9nrgqak076.jpg "/>
Most commands support multiple parameters in one command, for example, we use the following command to make two property modifications to a mailbox account:
Set-mailbox–identity robin.pang–maxsendsize 10mb–maxreceivesize 20MBOther Commands:
Set-sendconnector "to Internet" –enabled $false
Get-mailbox–database RDB01 | Remove-mailbox–whatif
650) this.width=650; "title=" 07.png "style=" height:131px;width:720px; "border=" 0 "hspace=" 0 "alt=" wkiol1tbdwiaj_ Fzaajmbjy-pkq350.jpg "src=" http://s3.51cto.com/wyfs02/M00/58/ED/wKioL1TBDWiAJ_fZAAJmbJY-PkQ350.jpg "width=" 720 " height= "131"/>
When you make some changes, for example: If you want to remove a mailbox account, you will be prompted for confirmation, for example:
650) this.width=650; "title=" 08.png "style=" height:120px;width:720px; "border=" 0 "hspace=" 0 "alt=" Wkiom1tbdjhazft0aad8zyfptoy818.jpg "src=" http://s3.51cto.com/wyfs02/M00/58/EF/ Wkiom1tbdjhazft0aad8zyfptoy818.jpg "width=" 720 "height="/>
of course, we will not be prompted to confirm when we do the following :
Remove-mailbox robin.pang–confirm: $false
Set properties for some mailbox users:
Set-mailbox–identity Robin.pang–office Sales
650) this.width=650; "title=" 09.png "style=" Float:none; "alt=" wkiom1tbdlkhcfzxaacbledupec163.jpg "src=" http:/ S3.51cto.com/wyfs02/m01/58/ef/wkiom1tbdlkhcfzxaacbledupec163.jpg "/>
to the AD To view the user's properties, you can see that the office has changed to Sales the
650) this.width=650; "title=" 10.png "style=" Float:none; "alt=" wkiol1tbdyndmrgdaagxcxsqqum607.jpg "src=" http:/ S3.51cto.com/wyfs02/m01/58/ed/wkiol1tbdyndmrgdaagxcxsqqum607.jpg "/>More Commands:
get-mailbox–organizationalunit ' corp.robin.com/viplab/ Group Headquarters / Technical Center '
650) this.width=650; "title=" 11.png "style=" height:153px;width:720px; "border=" 0 "hspace=" 0 "alt=" Wkiom1tbdlkxmcygaaebdrvavos436.jpg "src=" http://s3.51cto.com/wyfs02/M01/58/EF/ Wkiom1tbdlkxmcygaaebdrvavos436.jpg "width=" 720 "height=" 153 "/>
We can also use variables in the command line ( Note here that the double quotation marks of the second command ) :
$DepartmentOU = ' Administration Department '
get-mailbox–organizationalunit "corp.robin.com/viplab/ Group Headquarters /$DepartmentOU "
650) this.width=650; "title=" 12.png "style=" height:119px;width:720px; "border=" 0 "hspace=" 0 "alt=" Wkiol1tbdyrg1oo9aad2dks_f_k670.jpg "src=" http://s3.51cto.com/wyfs02/M02/58/ED/wKioL1TBDYrg1oO9AAD2DKS_f_ K670.jpg "width=" 720 "height=" 119 "/>
This article from "Robin's Home" blog, declined reprint!
One of the key concepts of Exchange, PowerShell
Start building with 50+ products and up to 12 months usage for Elastic Compute Service