Powershell test if executable in path -
in script i'm run command
pandoc -ss readme.txt -o readme.html
but i'm not sure if pandoc
installed. (pseudocode)
if (pandoc in path) { pandoc -ss readme.txt -o readme.html }
how can real?
you can test through get-command (gcm)
if (get-command "pandoc.exe" -erroraction silentlycontinue) { pandoc -ss readme.txt -o readme.html }
if you'd test non-existence of command in path, example show error message or download executable (think nuget):
if ((get-command "pandoc.exe" -erroraction silentlycontinue) -eq $null) { write-host "unable find pandoc.exe in path" }
try
(get-help gcm).description
in powershell session information get-command.
Comments
Post a Comment