Tuesday, June 29, 2004
  1. get-command

The idea of being able to see all the commands supported by a shell is pretty cool. Has this been there in the past? I doubt. This command outputs not only the standard commands that come with msh but also the cmdlets that have been added by the user.

  1. get-help

get-help followed by a command name gives a detailed help for that command. Try (get-help get-command).synopsis, the get-command here could be any other command. Cool?

  1. get-member

Any command gives its output as an object in msh. This object could offer a set of methods and properties. Get-member uses reflection and lets you see these members. For eg: get-command | get-member -methods lists the methods available for the command object

  1. Programmability on  the commandline – write functions, use foreach, if-else etc.
  2. out-*

Killer feature. Try get-process | tail | out-excel. Now try get-process | sort id | tail | out-chart processname, id. You are gonna love what you see J. For other output options, type get-command out-*

  1. –Whatif

What if you had a series of commands, pipes and weren’t 100% sure if it did what you thought it did. What if you spend 2 min thinking if you should press the carriage enter key or not.  You use exactly this feature => the –whatif feature provided by msh. You type in the command and append it with a –whatif. Now the output you see is the output that the command if executed would have given. This is a way to let you know the output of a command without it really executing. Should reduce the average tension in an admins life ;)
stop-process 12,4 -whatif

  1. errorpolicy –confirm

This option gives you an option Yes to all, No to all, yes, no and suspend. Suspend is new. Suspend launches a new shell, lets you explore and find out about the problem, exit and come back to the same option. The idea is that you are probably now surer of which option to choose.

  1. The idea of having cmdlet providers. [Yeah you can traverse the registry as though it were a filesystem. You can write your own providers!!]
  2. where/where-object/reduce-expression

lets you specify a condition, filter. For example.

                                                               i.      gps | where “processname -like n*”

                                                      ii.      $ps get-process

foreach ( $p in ps | where { $_.handlecount -ge 500 } | sort handlecount) {  $p.processname,$p.id }

 

That was a listing of some of the commands that are aha!!

Tuesday, June 29, 2004 2:47:09 AM (US Eastern Standard Time, UTC-05:00)  #    Comments [2]Trackback