Get-Command (which) by Joel Bennett 4 years ago
View followups from Joel Bennett | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/122"></script>download | new post
A function to replace Get-Command and output the commands in the correct order (the first one is the one the shell will use by default).
- ## This ought to be the same as Get-Command, except...
- ## it will output the commands in the actual order they would be used by the shell
- function which( [string]$command ) {
- $Script:ErrorActionPreference = "SilentlyContinue"
- Get-Command $command -commandType Alias
- Get-Command $command -commandType Function
- Get-Command $command -commandType Cmdlet
- Get-Command $command -commandType Script
- Get-Command $command -commandType Application
- Get-Command $command -commandType ExternalScript
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
PowerShell Code Repository