Finding Invalid Aliases

by Apr 22, 2010

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.

Twitter This Tip! ReTweet this Tip!