

Right-click the GPO created in the above step. Click Create a GPO in this domain, and Link it here. Right-click the OU of users you want to prevent them from shutting down the client computers. Open Group Policy Management ( Open Server Manager -> click Tools -> click Group Policy Management). Prevent Users from Shutting Down their Computer However, you can use a group policy to prevent them from shutting down or restarting the client computers.įollowing are step by step instructions written for this purpose. But for those who cannot use an Enterprise Solution this article can be helpful to restart all Computer by a One-Liner in PowerShell.Domain users are by default allowed to shutdown, restart, or put the domain-joined client computers to sleep. This approach is not a replacement for an Enterprise Solution like SCCM. $NoRestart.targetobject | Out-File C:\Temp\NoRestart.txt For checking run the following command to retrieve all “No Restart” computers by computername and to save them in a file. The list of computers that have not restarted will be saved by computer name. This information is stored in the variable NoRestart. ErrorsĪfter completing, you can see that my machine client01 is not accessible. The -ErrorVariable parameter stores errors in the variable NoRestart. The -ErrorAction parameter does not display any errors (computers in the database can be offline). The -Force parameter forces a restart even when users are logged on. Restart-Computer -ComputerName (Get-Content C:\Temp\computers.txt) -Force -ErrorAction Silentl圜ontinue -ErrorVariable NoRestart This could be unpleasant if you catch the “wrong”. Open files are not saved and the user is logged off. I recommend all readers to stop now and ask yourself: “Do you really want to restart all those computers?” 😉 Control the list of computers carefully. This can be done manually or by a Group Policies. The WMI inbound firewall rule must be enabled on all domain computers. (Get-ADComputer -Filter 'operatingsystem -notlike "*server*"').Name | Out-File C:\Temp\computers.txt Then you can search them by using the operating system attribute to catch all of them. The domain computers may be somewhere around, there is a tohuwabohu (a hot tip: Container Computers). You can also use a variable.Īs already mentioned, tidy environments are rare.

(Get-ADComputer -Filter * -SearchBase "OU=Workstations,DC=pagr,DC=inet").Name | Out-File c:\Temp\computers.txt If this is the case then the list of all computers can be retrieved there. In a cleaned up environment all domain computers are stored in a separate organizational unit. Preparation List all Computer Names by Oranizational Unitįirst, I need a list of all domain computers. In this article I show how to force restart of all domain computers by using the command Restart-Computer.
