Get full path of executable in PATH variable

Ever wanted to get the full path of an executable that is located in the global PATH variable? Maybe for configuration purposes? Take a look at the following snippet. It may help you:

(Get-Command -Name @("code.cmd")).Path | ForEach-Object {
	Write-Host "$(([System.IO.DirectoryInfo]$_).Parent.FullName)"
}

This will show the full path of the parent folder containing “code.cmd”. The term “code.cmd” could be replaced with “java”, “cmd”, “powershell” or whatever is configured in the global path. It could be useful to find out what version of a certain framework or program is used for example.