Shell – Execute command prompt file (.cmd) from within a PowerShell script

powershellscript

What command do I need to put in a .ps1 file to execute setup.cmd and make it a forced install?

I've tried to execute this command in powershell and its working:

PS C:\> c:\setup.cmd install-setupforced

I would like to know how I can use this command inside a .ps1 script.

Best Answer

I think you're asking how to run commands from a Powershell script... You probably wan to use the Invoke-Command cmdlet. Your script would look something like this:

Invoke-Command setup.cmd -ArgumentList install-setupforced

That may work. Please be sure to check out help Invoke-Command in Powershell.

Related Question