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

This topic contains 5 replies, has 3 voices, and was last updated by Profile photo of bvi1998 . bvi1998 . 5 months, 2 weeks ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #37412
    Profile photo of bvi1998 .
    bvi1998 .
    Participant

    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
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    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
    Profile photo of bvi1998 .
    bvi1998 .
    Participant

    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
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    On 2008, I always used schtasks.exe.

    #37423
    Profile photo of Richard Diphoorn
    Richard Diphoorn
    Participant

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

    #37564
    Profile photo of bvi1998 .
    bvi1998 .
    Participant

    Thanks Dave and Richard 🙂

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.