none
Start-Process -Credential on PSExcec RRS feed

  • General discussion

  • I am trying to run the command below in a powershell prompt and am able to run the command successfully, but psexec will hang at the prompt:

    Start-Process -Credential (Get-Credential -UserName AltDomain\Useraccount -Message "Enter your Password") -WorkingDirectory "<Path to PSTools>" `
    -FilePath "<Path to PSTools>\psexec.exe" -ArgumentList "-s -u AltDomain\Useraccount -p <password> \\<Computername> cmd"

    I found out that when I type in something on the psexec window nothing will show up, but if I clicked back on the powershell prompt the words that I typed would appear. I would have to go back and worth between windows just to run any commands. This issue doesn't appear when I run the script through Powershell ISE. Anyone know what's going on or how to get this running successfully?

    • Changed type Bill_Stewart Friday, January 26, 2018 3:05 PM
    • Moved by Bill_Stewart Friday, January 26, 2018 3:05 PM This is not psexec support forum
    Monday, December 4, 2017 5:50 PM

All replies

  • This is not a psexec support forum.

    If you want an interactive command-line PowerShell session on a remote computer, you would use Enter-PSSession.


    -- Bill Stewart [Bill_Stewart]

    Monday, December 4, 2017 5:55 PM
  • I'll check with sysinternals forum. Can't use Enter-PSSession as the winrm service is disabled.

    I figured out another way to get this to run:

    $Credential = (Get-Credential -UserName AltDomain\Useraccount -Message "Enter your Password")
    $Password=$Credential.GetNetworkCredential().Password
    
    $ProcessStartInfo = New-Object System.Diagnostics.ProcessStartInfo -Prop @{
        RedirectStandardError = $false
        RedirectStandardOutput = $false
        UseShellExecute = $false
        UserName = $Credential.GetNetworkCredential().UserName
        Domain = $Credential.GetNetworkCredential().Domain
        Password = $Credential.Password
        WorkingDirectory = "<Path to PSTools>"
        FileName = "psexec.exe"
        Arguments = "-s -u <AltDomain\Useraccount> -p $Password \\<Computername> cmd"
    }
    
            [Diagnostics.Process]::Start($ProcessStartInfo) | Out-Null

    • Edited by lytvinh Tuesday, December 5, 2017 5:27 PM
    Monday, December 4, 2017 7:11 PM