In my script I’m about to run a command
pandoc -Ss readme.txt -o readme.html
But I’m not sure if pandoc is installed. So I would like to do (pseudocode)
if (pandoc in the path)
{
pandoc -Ss readme.txt -o readme.html
}
How can I do this for real?
You can test through Get-Command (gcm)
If you’d like to test the non-existence of a command in your path, for example to show an error message or download the executable (think NuGet):
Try
in a PowerShell session to get information about Get-Command.