header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Commands fail with TaskScheduler
Last Post 20 Sep 2011 06:11 AM by Dan70402. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Dan70402User is Offline
New Member
New Member
Posts:2
Avatar

--
19 Sep 2011 12:44 PM
    I am trying to schedule some powershell scripts for system maintenance\automation.  I am running the scripts under a dedicated domain user account.  When I run Get-WMI or Get-Service from a scheduled tasks I receive an "access denied" in $ERROR.  When the same commands are run locally (same account) they succeed.  Some examples are below:

    In Task Scheduler:
       powershell -command &{Get-Service >> C:\testtask.txt}

    This will return nothing due to an access denied.

    In CMD:
       powershell -command &{Get-Service} >> C:\testcmd.txt}

    This will return all services as expected.


    Has anyone ever experienced this issue?  I also encounter it with Get-WMIObject.  As mentioned, this is local only so WinRM shouldn't be involved?  Regardless, WinRM is configured through GP and works great.  The issue only occurs from scheduled tasks.

    I replicated the issue on Win7 SP1 x64 and Server 2008 R2 SP1.

    Any help is greatly appreciated.

    Thanks



    halr9000User is Offline
    PowerShell MVP, Site Admin
    Advanced Member
    Advanced Member
    Posts:565
    Avatar

    --
    19 Sep 2011 01:15 PM
    Have you tried checking the "run with highest" box?
    Community Director, PowerShellCommunity.org
    Co-host, PowerScripting Podcast
    Author, TechProsaic
    Dan70402User is Offline
    New Member
    New Member
    Posts:2
    Avatar

    --
    20 Sep 2011 06:11 AM
    Thanks for the reply.  Yes, I have enabled the "run with highest privileges" checkbox in the TaskScheduler.  I have also tried running the command with the -EnableAllPrivileges switch.  While reseraching I found similiar issues that required an "-Authentication 6" for PacketPrivacy, but this only applies to remote connections.  This is local only.

    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer