Cleaning up obsolete Windows PowerShell Aliases

Rate This
  • Comments 1

Over the course of time, I've written a number of functions & cmdlets and then created aliases for those.  Many of those where Ad Hoc and I've since thrown them away but I still have the aliases sticking around.  Here is a quick and easy way to determine the validity of your aliases

gal |%{if (!(gcm $_.Definition -ea SilentlyContinue)) {$_}}

Jeffrey Snover
Windows PowerShell Architect

PSMDTAG:ENVIRONMENT: cleaning up Aliases

Leave a Comment
  • Please add 1 and 3 and type the answer here:
  • Post
  • Jack pot!

    [^_^]PS[331]>gal | % { if (!(gcm $_.Definition -ea SilentlyContinue)) { $_ } } | ft -auto

    CommandType Name Definition
    ----------- ---- ----------
    Alias       gs   Get-MshSnapin
    Alias       gpv  get-provider
    Alias       ndv  new-drive

    Thanks for the cool tip~
Page 1 of 1 (1 items)

Cleaning up obsolete Windows PowerShell Aliases