locked
Invoke-Command to a specific user profile RRS feed

  • Question

  • Hi guys,

    i need to start an application on the remote computer, it generate an outlook report.

    The big problem is that the application get values from the user profile where account is configurated, so i can't connect with domain admin like this, becouse the remote outlook administrator account is obviously empty.

    How can i solve ?


    cls
    $domainuser = "DOM\administrator"
    $domainpassword = "123456" | ConvertTo-SecureString -AsPlainText -Force
    $domaincredentials = New-Object System.Management.Automation.PSCredential ($domainuser, $domainpassword)
    <#
    Invoke-Command -ComputerName PC-W7 -Credential $domaincredentials -ScriptBlock {
    c:\script\mailreport.exe /scomma "" >> c:\script\mailreport.csv
    }
    #>
    
    c:\script\psexec \\PC-W7 -i -u dom\user -p abcdef cmd /k cd c:\script\ '&' mailreport.exe /scomma >> c:\script\mailreport.csv  #2> $null
    Monday, May 22, 2017 1:19 PM

Answers

  • Hi Ramses,

    you can do this by granting powershell remoting permission to the user you are impersonating.

    If you want to avoid this, you can configure a scheduled task to run on the computer under that account. Then you could run psexec or runas on the remote system to run under the second user.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by Ramses147 Monday, May 22, 2017 3:24 PM
    Monday, May 22, 2017 2:10 PM

All replies

  • Hi Ramses,

    you can do this by granting powershell remoting permission to the user you are impersonating.

    If you want to avoid this, you can configure a scheduled task to run on the computer under that account. Then you could run psexec or runas on the remote system to run under the second user.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by Ramses147 Monday, May 22, 2017 3:24 PM
    Monday, May 22, 2017 2:10 PM
  • Thanks FWN maybe i will choose for psexec :-|
    Monday, May 22, 2017 3:32 PM