Powertip Of The Day-finding invalid aliases

Source: Internet
Author: User

Original article address:Http://app.en25.com/e/es.aspx? S = 1403 & E = 4778 & elq = baf9b44a60364f3fbf25d7590e9cb761

Original article:

When you create new aliases with set-alias, powershell does not check whether the target you specify is valid. instead, this is checked only when you use the alias. this line can help you to find all aliases with invalid targets:

Get-alias | foreach-object {If (! (Get-command $ _. Definition-ea silentlycontinue) {$ _}}

If it returns nothing, then all is fine.

 

Translation:

When usingSet-aliasWhen creating an alias,PowershellIt does not check whether the alias is valid. However, it is checked only when used. The followingCodeThis helps you find all invalid aliases:

Get-alias | foreach-object {If (! (Get-command $ _. Definition-ea silentlycontinue) {$ _}}

If nothing is returned, it means it is legal.

 

Notes:

-Ea =-erroraction

Get-command used to retrieve the list of all available cmdlet

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.