Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I am trying to run a command in CMD, but would like to run in through PowerShell.
Invoke-Item opens CMD, but I don't how to pass in program.exe argument > file.txt
Invoke-Item
program.exe argument > file.txt
To run cmd.exe from PowerShell, you don't need to use invoke-item e.g.:
cmd /c c:\windows\system32\ipconfig > file.txt
However, why not just run?
ipconfig > file.txt
Add a comment
try passing the command in directly with the full path qualifier of program.exe like:
$test= "c:\windows\system32\program.exe argument > file.txt" Invoke-Expression $test
.exe
Invoke-Item c:\windows\system32\cmd.exe program.exe argument > file.txt
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.