Powertip of the day from powershell.com summary last week (3)

Source: Internet
Author: User

 

Lower process priority

Lowering process priority

Http://app.en25.com/e/es.aspx? S = 1403 & E = 7006 & elq = d22c2238899d4fc7a2952a7e42ab8c81

The following command reduces the priority of notepad processes in the current process to belownormal. The default process priority is normal.

Get-process notepad | foreach-object {$ _. priorityclass = "belownormal "}

 

 

Add a new event log Source

&

Write logs

Adding new event log sources

&

Writing your own event log entries

Http://app.en25.com/e/es.aspx? S = 1403 & E = 7042 & elq = f238ef0ee41f4a8cb5ecbd049488bfd1

&

Http://app.en25.com/e/es.aspx? S = 1403 & E = 7110 & elq = dd228c9d63244a3a99a5d9b652ec047f

If you want to use Event Logs, you must first register one. Make sure that the account to be executed has administrator privileges.

New-Eventlog application powershellscripts

After registration, you can use the following methods to write logs:

Write-Eventlog-LOGNAME application-source powershellscripts-entrytype warning-eventid 12345-message 'This is my message'

Logs are written in the operating system.

 

 

View the folder directory on your desktop

Finding a user's desktop folder

Http://app.en25.com/e/es.aspx? S = 1403 & E = 7183 & elq = bd457dddf07d405abb3b8936a1d71895

It is mainly obtained through the Environment class in. Net:

[Environment]: getfolderpath ("desktop ")

In addition, you can use the following command to obtain all available directories:

[Enum]: getnames ([system. Environment + specialfolder])

 

 

Operation Method under path

Working with path names

Http://app.en25.com/e/es.aspx? S = 1403 & E = 7247 & elq = 199d2ebb698c4ca28036d31a85661fa5

The system. Io. Path class in. Net has many useful static methods. You can use the following command to obtain a list of supported methods:

[System. Io. Path] | get-member-static

The following method demonstrates how to change the extension of a file:

[System. Io. Path]: changeextension ("test.txt", "PS1 ")

 

 

 

The above is from powershell.com

Powertip of the day from February 2 to 6

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.