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