Tuesday, 16 March 2010

Set-ProgrammerAlias.ps1


  1. <# 
  2. .SYNOPSIS 
  3.     This script creates a function to set aliases for all Cmdlets which omit the '-' 
  4. .DESCRIPTION 
  5.     This script defines a function which uses Get-Command to find all
  6.     cmdlets. For each of them, it then creates an alias which omits
  7.     the "-". This function  was oritinally written by Jeffrey Snover for
  8.     Monad back in the day, but I updated it slightly for PowerShell V2. 
  9.     Updated after a comment to be a tad shorter. 
  10. .NOTES 
  11.     File Name  : Set-ProgrammerAlias.ps1 
  12.     Author     : Jeffrey Snover - jsnover@microsoft.com 
  13.     Updated by : Thomas Lee - tfl@psp.co.uk 
  14.     Requires   : PowerShell Version 2.0 
  15. .LINK 
  16.     This script posted to: 
  17.         http://www.pshscripts.blogspot.com 
  18. #> 
  19. ## 
  20. # Start of Script 
  21.  
  22. function Set-ProgrammerAlias { 
  23.  get-command -Com Cmdlet | % {set-alias $($_.Verb + $_.Noun) $_.Name}  
Technorati Tags: ,,,

1 comment:

10litrov said...

Why don't you use
get-command -CommandType cmdlet
for listing cmdlets only?