One of the key concepts of Exchange, PowerShell

Source: Internet
Author: User
Tags object model


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 '

-connectionuri http://mbx01/PowerShell/'

-authentication Kerberos '

Import-pssession $Session

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 reading

using 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:

Get-help Get-mailbox–full

You can also use the following switch parameters to obtain specific information:

Get-help cmdlet

Detailed: The Detailed view provides a description and an instance of the parameter, which can be used in the following syntax:

Get-help <cmdletname>-detailed

Examples: you can see multiple instances using this command, which can be used as follows:

Get-help <cmdletname>-examples

Full : Use this parameter to view the full contents of the Help file, with the following syntax:

Get-help <cmdletname>-full

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=" 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 explain

more Command Instances

Perhaps, when you do not know the full name of a command, we can also search by command, for example:

Get-command *mailbox*

You can also use a -verb Parameter to find all the arguments that begin with this particular verb, for example:

Get-command–verb Set

To search for a specific noun, you can specify a noun parameter in the following format:

Get-command–noun Mailbox

650) this.width=650; "title=" 02.png "style=" height:167px;width:720px; "border=" 0 "hspace=" 0 "alt=" Wkiom1tbdjcx8hwyaafkqmafdfc938.jpg "src=" Wkiom1tbdjcx8hwyaafkqmafdfc938.jpg "width=" 720 "height=" 167 "/>

Other help command formats:

Get-help About_core_commands

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=" 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=" 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 usage

Understanding 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:/ "/>

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:/ "/>

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 20MB

Other Commands:


Set-sendconnector "to Internet" –enabled $false

Enable-mailbox robin.pang–archive

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=" "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=" 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:/ "/>

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:/ "/>

More Commands:

get-mailbox–organizationalunit ' Group Headquarters / Technical Center '

650) this.width=650; "title=" 11.png "style=" height:153px;width:720px; "border=" 0 "hspace=" 0 "alt=" Wkiom1tbdlkxmcygaaebdrvavos436.jpg "src=" 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 " 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=" K670.jpg "width=" 720 "height=" 119 "/>

This article from "Robin's Home" blog, declined reprint!

One of the key concepts of Exchange, PowerShell

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.