get-command -CommandType Application | ? {$_.Name -like '7z.exe'}
get-command
gets all known commands; the -like
operator filters out what is needed , in this case '7z.exe'.
7z.exe is a Application (not a Powershell Cmdlet), thus the switch -CommandType Application
. It may or may not have an entry in the registry.
Without the -Commandtype switch, you would get a clunky error (which you also manage with a try/catch block, that would be clunky)
Cheers, Sudhi