7.10. Find Out Which Command Is Being RunUse 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" } } } |