Graceful shutdown


I’m looking to remotely power down some servers. It would appear the cmdlet to use is “stop-computer”. However, I need this to gracefully shutdown the server, but not allow for it to be stopped by anything. For example, a logged on user.

I think using the “force” argument would work for handling logged on users. My concern is that one of the servers is a SQL server and using the “force” argument wouldn’t allow for SQL to shutdown safely, does anyone know the affect this would have on SQL, or have any better suggestions?

Any information is welcome.


Why not gracefully shutdown Sql Server first?
If you’re scripting a shutdown, not that big a step to shutdown Sql first, if it’s on the server being shutdown.
But if you don’t want to / can’t, you could (a) do a Checkpoint first to ensure all transactions hardened to the log or (b) just Shutdown and the Sql Server will roll forward/rollback the transactions that were still open, but of course that option has risks.

Hi Iain,

I hadn’t thought about shutting down SQL first. This is due to a lack of knowledge rather than not wanting to. I was also trying to keep the script reasonably simple.

What I am trying to achieve the is the smooth shutdown of a SCOM 2012 environment. I need to shutdown 3 managment servers, followed by an operational DB(SQL) server and then the reporting server (SQL).

I’ll have a look into shutting down sql with powershell and no doubt come back with more questions.

Thanks for your reply.