I am looking to run an exe from powershell using a credential. I want the output to be in the same window. This is how my powershell looks.
Start-Process documentation: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-6
$username = 'user'
$password = 'password'
$credentials = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))
$pathNew = "c:\pathtomyexe\text.exe"
Start-Process $pathNew -NoNewWindow -Credential ($credentials) -PassThru -Wait
With -Credential ($credentials) a new window is launched.
When I run Start-Process without -Credential, I get result in the same window as expected.
Start-Process $pathNew -NoNewWindow -PassThru -Wait
What am I doing wrong? Any pointers?