Powershell to CMD

Hi,

When I call CMD as a different user in powershell, can I pass commands from Powershell to the CMD for execution?

Example:

Start-Process cmd -Credential (Get-Credential "$env:USERDNSDOMAIN\")

Once the window is open, I would like for it to process the command in the new CMD window:

Echo Hello World!

Thank you!

of course, Use -ArgumanetList parameter will do the job.

Start-Process -FilePath cmd.exe -ArgumentList 'echo HelloWorld' -Credential (Get-Credential)

It’s always recommended and good read the help documentation for any cmdlet in PowerShell.

Get-Help Start-Process -ShowWindow