Hello,
I am looking to set a task scheduler to power off our school computer labs each evening.
I am trying to deploy a powershell script to a device group in intune but it fails. We have some AD domain computers which I deployed the same script via group policy and it worked.
Has anyone managed to get this working successfully?
Here is my script:
# The name of your scheduled task. $taskName = "Shutdown Computer" $User= "NT AUTHORITY\SYSTEM" # Describe the scheduled task. $description = "Shuts computer down daily at 7:00PM" # Create a new task action $taskAction = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument 'Stop-Computer -Force' #Create task trigger $taskTrigger = New-ScheduledTaskTrigger -Daily -At 7PM # Register the new PowerShell scheduled task # Register the scheduled task Register-ScheduledTask -TaskName $taskName -Action $taskAction -Trigger $taskTrigger -Description $description -User $User
Any help appreciated.
Thank you.