No announcement yet.

powershell script not working like it should in task schedule

  • Filter
  • Time
  • Show
Clear All
new posts

  • powershell script not working like it should in task schedule

    I have a powershell script that grabs all user account lockout ,unlocks ,disabled, enable events from the domain controllers - groups them by user and saves foreach user a text files with all his events in a share at the network. (the script creates a new folder for each day inside the share)
    I created a task schedule on a 2008r2 server to run the script every 15 minutes. it is set to run as a domain administrator, and with highest privileges. the action target is set to powershell.exe and as arguments " -executionpolicy bypass -file <path to script>"
    The task finishes with a 0 status code each time it runs. however it never saves the logs. running the script as administrator manually works as it should.
    I didn't find yet a pattern, but sometimes the script works. but from the looks of it if the folder is created manually, then user logs can be created for the first script run since the creation of the folder. the second run would not produce any output.
    It's not a matter of permissions, since other powershell scripts I have written and ran (also from task schedule), manage to save files to the same share (at csv format though). I am certain all settings are correct but I am going insane trying to figure out what is the problem here.
    please help.