Reputation: 71
I am working on translating a program written as a CMD batch file into PowerShell and ran into the below code snippet. I am unsure on how to translate this into PowerShell. I am particularly interested in translating line 1 (2>NUL 1>NUL) and line 2 (errorlevel 1).
If you were writing this entire code snippet in PowerShell how would you do it and why.
Could someone please help? Thanks.
"C:\Program Files (x86)\erl5.8.5\erts-5.8.5\bin\erlsrv" list RabbitMQ 2>NUL 1>NUL
if errorlevel 1 (
"C:\Program Files (x86)\erl5.8.5\erts-5.8.5\bin\erlsrv" add RabbitMQ
)
Upvotes: 1
Views: 393
Reputation: 2449
2>NUL and 1>nul means redirect all standard output and error output to null
should translate into someting like:
if ($LASTEXITCODE eq 1)
Upvotes: 1