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

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -