Powershell and Task Scheduler

This topic contains 4 replies, has 3 voices, and was last updated by  Thomas 7 months, 3 weeks ago.

  • Author
    Posts
  • #63123

    Thomas
    Participant

    Hi guys

    Got a minor issue here that is driving me nuts. I have made a script that crawls a lot of XML config files over a UNC path. It works perfectly when running normally, but setting it up as a Task it fails at accessing the UNC share... Any one got a good hint on what to do next. Below is just a test script i wrote to see it happen.

    #Creating variables and filling in default data for file crawl
    $StartPath="\\ServerName\Customers\" #location of starting directory
    #Done creating variables and arrays
    
    $Script:Customers = (Get-ChildItem $StartPath -Directory)
    

    My script is split up into functions. I'm using the $Customers later in the script, so that is why I load it as $Script:Customers so I can use the result in another function.

    I have tried running the task as SYSTEM, admin and admin with highest privileges.

    Thanks

  • #63126

    Hi

    Running test and task with same account or rights?

    Jake

    • #63129

      Thomas
      Participant

      Hi Jake

      I login to the server with my normal user, but start Powershell ISE as administrator and it works just fine.
      I'll try tomorrow to login in with local admin and test, just be make sure.

  • #63130

    Richard Siddaway
    Moderator

    Running as local admin could be the issue – that account won't have rights to a share on another machine

    • #63189

      Thomas
      Participant

      ah yes that seemed to do the trick. Used my own user in the admin group and can now run it with highest privileges.

      thanks 🙂

You must be logged in to reply to this topic.