![]() ![]() ![]() ![]() Disable or Prevent Shutdown Option using Group Policy Note that this policy setting does not prevent users from running Windows-based programs that perform these functions. Luckily this policy setting is available in Windows Server and we will see the steps to implement that in this post. So the only option that a user could do after the work is complete is to log off the computer. The company wanted to prevents users from performing the following commands from the Start menu or Windows Security screen such as Shut Down, Restart, Sleep, and Hibernate. I hope it goes without saying that this is pretty powerful ju-ju so be sure you've tested your scripts and tried out these commands in a non-production environment.Disable or Prevent Shutdown Option using Group Policy Few years ago when i was working as system admin, I was asked to apply a group policy to prevent the users from shutting down their computer. But personally many of them are duplicated with cmdlets like Restart-Computer and Stop-Computer given a choice I prefer to use a cmdlet. If you look at the MSDN documentation for this method you'll discover other method parameter values, which you can certainly use. PS C:\> Get-WmiObject win32_operatingsystem -ComputerName Quark | Invoke-WMIMethod -name Win32Shutdown -ArgumentList have to specify the value for -ArgumentList as an explicit array. But if the user has open files or if the default method fails, you can always resort to a forceful logoff: The default is 0 which means do a simple logoff. The Win32Shutdown method can accept parameters. PS C:\> Get-WmiObject win32_operatingsystem -ComputerName Quark | Invoke-WMIMethod -name Win32Shutdown I found it just as easy to pipe a WMI object from Get-WMIObject to Invoke-WMIMethod: I recommend using Invoke-WMIMethod because it supports -WhatIf and -Confirm. Be aware this will force applications to close with the potential loss of unsaved work.Īnother option for rebooting or even logging off is to use the Win32_OperatingSystem WMI Class and the Win32ShutDown method. However, you can force a reboot using - what else? - the -force parameter. ![]() The Restart-Computer cmdlet will fail, if a logon session is detected. I'll get prompted for the password, but then this credential will be used for every computer in the list. PS C:\> restart-computer (get-content c:\work\computers.txt) -credential "mycompany\administrator" PS C:\> restart-computer (get-content c:\work\computers.txt)īecause the cmdlet is using WMI objects and methods under the hood you can specify alternate credentials, either a saved credential object or a user name: PS C:\> restart-computer "server01","server02","server03" -whatifīy the way, here's how you could shut down a list of computers: This is especially helpful if I'm rebooting a bunch of servers: Although I didn't really I took advantage of the -WhatIf parameter to verify my command. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |