Jump to content

Recommended Posts

Posted

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.

Posted

IIRC PowerShell scripts in Intune are only run once, and even then they only run on bootup.

 

Have you checked the logs in the C:\ProgramData\Microsoft\IntuneManagementExtension\Logs folder? That should also tell you whether the script has run, or if it has errored.

Posted
It works an admin user account but not a standard user.

 

That makes sense. Why would a standard user be able to schedule a task that affects the whole system?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...