First PowerShell script--powershell three minutes (ix)

Source: Internet
Author: User
Tags message queue
Before we tell the basics, now we're going to start writing the most elementary script.

There are a lot of scripting tools, there are text documents, there are PowerShell Ise,powershell studio, etc., here the system comes with PowerShell ISE

Here you still have to remember to run as an administrator, or the lack of sufficient permissions to cause the command to run failed

OK, let's find the most common command, assuming we want to query the previous day's Exchange mail queue for information such as spam.


So first, the ISE is not an Exchange-aware command by default, so you need to add the Exchange snap-in first

Then enter the command to query the message queue

Because the front-end has multiple servers, the default Get-messagetrackinglog can only be queried in the current server, so multiple servers need to be passed in as objects

Then increase the number of returns limit, prevent exceeding the maximum value, cause cannot display

and increase the time limit.

When when, press F5 to run a bit

Well, it's going to work, then continue to optimize

Because of the current value of the time here, so every time is June 4 to June 5, can not be modified every time this, we write the current date minus one day good

Try it, no problem.

Next, save this file as a. ps1 format OK

So how to use this script, when you need to query, open the PowerShell window directly, run the PS1 file can be

Of course, if your mail execution is also possible, but the execution will automatically close the window, you can add a paused command in the script to prevent closing



All right, I'll introduce you to this in three minutes today, and you can write the usual commands.


First PowerShell script--powershell three minutes (ix)

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: info-contact@alibabacloud.com 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.