Create a scheduled task on a remote computer (Windows 2008)

Welcome Forums General PowerShell Q&A Create a scheduled task on a remote computer (Windows 2008)

This topic contains 5 replies, has 3 voices, and was last updated by

 
Participant
2 years, 10 months ago.

  • Author
    Posts
  • #37412

    Participant
    Points: 31
    Rank: Member

    Hi, I have been struggling with a PS script where I am trying to execute a batch job on a remote computer. The batch job resides on a network share, so I will be using a UNC path.
    In the script, the user name, password, and computer name are queried.
    Besides trying various scheduled tasks, etc, I am now to the point of using invoke-command (I seem to remember Don says never to use that 🙂 ) ....

    Here is my command:

    Invoke-Command -ComputerName name -ScriptBlock { Start-Process "\\path\pleasehelpimgoingcrazy.cms" -verb runAs }

    I am getting an access denied error. I am using my account with the highest privileges. Can someone help?

    Thanks!

  • #37413

    Member
    Points: 0
    Rank: Member

    This is the "second hop" problem of PowerShell remoting. If you search for that term you'll find tons of results, but the short answer is that you need to use either Kerberos delegation (in an AD environment where this is possible) or CredSSP.

  • #37415

    Participant
    Points: 31
    Rank: Member

    Thanks Dave. Would it be easier to use a scheduled task then? I have had my issues with that as well, using an XML file for the task.
    If you were to use a scheduled task, which method would you use to set it up? Besides using schtasks.exe (always some issue with that 🙁 ) ... and I have tried New-Object -ComObject("Schedule.Service") .... but I seem to always have issues with permissions also.
    Which poison would you pick? 🙂
    Thanks!

  • #37418

    Member
    Points: 0
    Rank: Member

    On 2008, I always used schtasks.exe.

  • #37423

    Participant
    Points: 26
    Rank: Member

    For using credssp, you can check my post here how to do it trough a GPO. Not the safest thing, but it works nevertheless. 🙂 https://powershell.org/2015/06/18/quick-tip-enable-credssp-trough-gpos/

  • #37564

    Participant
    Points: 31
    Rank: Member

    Thanks Dave and Richard 🙂

The topic ‘Create a scheduled task on a remote computer (Windows 2008)’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort