Shutdown windows devices in Intune

nasha mehr 76 Reputation points
2022-11-07T17:32:57.167+00:00

I would like to shutdown windows devices every night at 10 p.m. Is there any way to do that with Intune policies?

Thanks for your help

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,975 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,660 questions
Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
4,593 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lu Dai-MSFT 28,366 Reputation points
    2022-11-08T07:31:36.21+00:00

    @nasha mehr Thanks for posting in our Q&A.

    For this issue, there is no such built-in setting in intune. However, we can deploy a script to make it.

    Please deploy the following scripts via intune and then we can see the task scheduler added in the device. When the time comes, the device will shutdown.
    https://learn.microsoft.com/en-us/mem/intune/apps/intune-management-extension

    # The name of your scheduled task.  
    $taskName = "Shutdown Computer"  
      
    $User= "NT AUTHORITY\SYSTEM"  
      
    # Describe the scheduled task.  
    $description = "Shuts computer down daily at 10:00PM"  
      
    # Create a new task action  
    $taskAction = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument 'Stop-Computer -Force'  
      
    #Create task trigger  
    $taskTrigger = New-ScheduledTaskTrigger -Daily -At 10PM  
      
    # Register the new PowerShell scheduled task  
    # Register the scheduled task  
    Register-ScheduledTask -TaskName $taskName -Action $taskAction -Trigger $taskTrigger -Description $description -User $User  
    

    Here are some screen shots in my test.
    258134-image.png

    258185-image.png

    Hope it will give you some ideas.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. S.Sengupta 16,561 Reputation points MVP
    2022-11-08T06:10:52.987+00:00
    0 comments No comments

  2. nasha mehr 76 Reputation points
    2022-11-08T19:54:47.263+00:00

    Thank you it worked.


  3. nasha mehr 76 Reputation points
    2022-11-09T20:16:20.85+00:00

    Is there any way to run this script in admin mode?
    I understand that the script runs on users who have admin privilege and without admin privilege it doesn't.

    I did some changes but none of them works.

    #The name of your scheduled task.  
     $taskName = "Shutdown Computer"  
    
     $User= "NT AUTHORITY\SYSTEM"  
    
     # Describe the scheduled task.  
     $description = "Shuts computer down daily at 3:10PM"  
    
     **$principal = -RunLevel Highest**  
    
     # Create a new task action  
     $taskAction = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument 'Stop-Computer -Force'  
    
     #Create task trigger  
     $taskTrigger = New-ScheduledTaskTrigger -Daily -At 3:10PM  
    
     # Register the new PowerShell scheduled task  
     # Register the scheduled task  
     Register-ScheduledTask -TaskName $taskName -Action $taskAction -Trigger $taskTrigger -Description $description -User $User **-Principal $principal**  
    

    The name of your scheduled task.

     $taskName = "Shutdown Computer3"  
    
     **$User= "AzureAD\username"  
     $Password= "Password**"  
    
     # Describe the scheduled task.  
     $description = "Shuts computer down daily at 1:30PM"  
    
     # Create a new task action  
     $taskAction = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument 'Stop-Computer -Force'  
    
     #Create task trigger  
     $taskTrigger = New-ScheduledTaskTrigger -Daily -At 1:30PM  
    
     # Register the new PowerShell scheduled task  
     # Register the scheduled task  
     Register-ScheduledTask -TaskName $taskName -Action $taskAction -Trigger $taskTrigger -Description $description -User $User **-Password $Password**  
    

  4. nasha mehr 76 Reputation points
    2022-11-09T21:06:51.303+00:00

    No i mean, I would like to run this script on all users but the script runs on users who are admin. It doesn't work on standard users.

    0 comments No comments