2 Replies Latest reply on Feb 22, 2020 5:22 AM by kotten33

    invoke-vmscript and start a schedule task that is run as system

    kotten33 Lurker

      Now i have spent much to time to solve this, hope someone of you guys have a solution for me. What is then i want to achieve?

       

      I have computers that are not accessable through powershell remoteing or another remote. So my last hope is that i can
      do it through invoke-vmscript. I do many other things through invoke-vmscript so i know it is working.

       

      I have a schedule task that runs as system with highest privileges and runs whether a user is logged on or not.

      This task i am trying to start through invoke-vmscript

       

       

      The script look like this, i have the script at work so some characters can be wrong, but you can see sort of what i am trying to do

      The error is like this "This operation requires an interactive window station"

      My shedule task is a powershell script that is on netlogon share.

      -------------------------------------------------------------------------------------------------------

      $scripttext = '

           schtasks /run /tn ThisIsMyScheduleTaskName

      '

      invoke-vmscript -vm $vm -scripttext $scripttext -guestcredential $Cred

      -------------------------------------------------------------------------------------------------------

       

      What i can understand is the you must start schedule job as admin. If i on the remote computer start cmd and run schtasks,i

      got access denied. But if i start cmd as admin and then run schtasks, it works.

       

      I can run this on the remote computer: Start-Process -FilePath cmd.exe -verb runas

      Now cmd is starting as admin and i can start my job

       

       

      I have also tried with start-scheduledtask in scripttext block but same error.

       

      I have also tried to disable UAC, and this have nothing to do with a schedule task

       

      i have domain admins to use, so i think i can do the most of things.