Wednesday, June 14, 2017

Nuke the entire site from orbit (close-WinsAll.ps1 Powershell script)

6/14/2017: One of the distinct 'costs' of running Office 365/Office 2016 at the office, seems to be that I spend a lot more time:
  1. Shutting down my work box for patching (now that both centralized patch management AND Office 365, independently do their own self-scheduled patching passes),
  2. and, much more frequently and defensively rebooting my box to try to scrape a few more ounces of performance from Word/Excel2016's bloated mass and resource sucking appetite.  
Both of which motivations naturally mean I'm trying to get faster reboots through on my box -- and this is coming from a guy that for the last 4-5 years has consistently hibernated his laptop at each day's end, to try to hit the ground running the next day, from the point I left off. :^|

Anyway, needless to say, the prospects and days of running a given 'up' session of Win7 for, "a couple of weeks" a stretch, appear to be long, long gone. Well, until they hand me a 36gb laptop (and some down time from work burn, to reinstall everything back to spec). But I digress....

So what's the point of this post? Simple: I've got a small and handy script I use, to get my box knocked down and into a reboot POST-HASTE!.

close-WinsAll.ps1 goes through and quickly does the following:
  • Issues a 'CloseWindow' on all visible desktop processes: Causing each to prompt for a save, if they're in an unsaved state, 
  • ... and then issues a 'Quit' on all Control Panel or  Explorer windows. 
Net result after a pass: Everything that can be closed, closes. And everything that needs an explicit save, is left with a save dialog popped. Confirm or cancel the save prompts,hit ctrl+alt+del, pick Reboot, and you're off to a Refreshening™ as fast as your wee little fingers can take you. :D

Here's the code

No comments:

Post a Comment