So I'm trying to run a powershell script on a schedule. Every morning at 6am, repeat every hour of the day. Here is the script itself:
Get-Content C:\Users\administrator\Desktop\users.txt | ForEach-Object {
Set-AdUser -Identity $_ -LogOnWorkstations $null
}
Now, the script works flawlessly when I execute it myself. But it seems as if the script won't properly run when its being scheduled to execute. My thoughts is that the execution policy keeps asking if its safe to run the script prior to running it. If anyone else agrees that this might be the reason the script can't start on its own, could you please provide me a solution around this barrier?
Get-ExecutionPolicy -List
say? What is the specific command lines for the scheduled task?logonWorkstations
attribute?