Section 7.10. Find Out Which Command Is Being Run


7.10. Find Out Which Command Is Being Run

Use a function to list all possible matches for an executable command in the order in which they are searched:

     function which {         param($search)         # look for the search term in the possible invocation list         get-command * | where-object { $_.Name -like $search }         # look for the search term with possible extensions         foreach ($ext in $($env:PATHEXT).Split(";"))         {             get-command * | where-object { $_.Name -like "$search$ext" }         }     }




Monad Jumpstart
Monad Jumpstart
ISBN: N/A
EAN: N/A
Year: 2005
Pages: 117

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net