Disable Windows Server 2012 R2 Automatic Maintenance Using PSEXEC
This is one of those articles that I wrote out of frustration: This time the cause of my frustration is the automatic maintenance feature in Windows Server 2012 R2. I’ve been on a training tour in Australia for the last two weeks, visiting various customers and delivering customized training for them. During all of my sessions, I used several virtual machines running Windows Server 2012 R2 that I used for demonstration purposes. These VMs were booted from a pre-configured snapshot state. I would then use them for a couple of days, and when done I would restore them to the snapshot state.
During my presentations and demos I discovered that sometimes my VMs would exhibit a nasty performance lag: Nothing worked, CPU usage was as high as 100 percent without me doing anything, and apps and tools that I needed — even simple ones such as Notepad — would take forever to start. One of my VMs ran SQL Server, two others were domain controllers, and nothing seemed to work.
After some investigation I found that it wasn’t my laptop, which is a powerful Lenovo T430S with 16GB or RAM and two fast SSD disks and an Intel i7 CPU. It also wasn’t my hypervisor software, and it wasn’t the food I ate for lunch that day. It was something else that is nasty and evil: Automatic Maintenance.
Windows Server 2012 R2 Automatic Maintenance
The only hint, besides the spiking CPU and awful performance, is the tray icon seen here:
What is “Inside Microsoft Teams”?
“Inside Microsoft Teams” is a webcast series, now in Season 4 for IT pros hosted by Microsoft Product Manager, Stephen Rose. Stephen & his guests comprised of customers, partners, and real-world experts share best practices of planning, deploying, adopting, managing, and securing Teams. You can watch any episode at your convenience, find resources, blogs, reviews of accessories certified for Teams, bonus clips, and information regarding upcoming live broadcasts. Our next episode, “Polaris Inc., and Microsoft Teams- Reinventing how we work and play” will be airing on Oct. 28th from 10-11am PST.
The Windows Server 2012 R2 automatic maintenance tray icon.
(Image: Daniel Petri)
Looking at Task Manager’s performance tab, you can’t see the CPU spike, it’s constantly at 100%:
Windows Server 2012 R2 automatic maintenance CPU usage.
(Image: Daniel Petri)
Digging deeper you see that it is a process called “TiWorker.exe” that’s responsible for the CPU hell:
Viewing TiWorker.exe CPU usage in Windows Task Manager. (Image: Daniel Petri)
This is an automated scheduled task that comes pre-configured in Windows Server 2012 R2, both Core and GUI versions. It runs each day at 2:00 AM by default. Judging by the text provided in the UI, it should only run when “you’re not using your computer.”
The problem is that a server is seldom used by a user, unlike a workstation computer. A server does stuff in the background, runs VMs (if it hosts the Hyper-V role, for example), hosts shares, runs anti-virus software and much more. They all just stop responding until this process is done.
You can manually stop the maintenance process like this:
Attempting to stop the Windows Server 2012 automatic maintenance program manually. (Image: Daniel Petri)
Selecting ‘Stop Maintenance’ in the Windows Server 2012 R2 Action Center. (Image: Daniel Petri)
You think that by pressing the “Changing maintenance settings” you can make it go away:
Selecting ‘Change maintenance settings’ in the Windows Server 2012 R2 Action Center. (Image: Daniel Petri)
But no, there’s only a limited set of options you can change, and disabling it is not one of them. It will always come back to haunt you!
Automatic maintenance settings in the Windows Server 2012 R2 Action Center. (Image: Daniel Petri)
If you go to Task Scheduler in Administrative Tools, you can see the task running:
The manual maintenance task running in Task Scheduler. (Image: Daniel Petri)
In reality, the “Maintenance Configurator” task is the one responsible for the task, but if you try to disable it, you cannot:
Attempting to disable the maintenance configurator in Windows Server 2012 R2. (Image: Daniel Petri)
Denied! Attempting to disable the maintenance configurator in Windows Server 2012 R2. (Image: Daniel Petri)
Disabling Windows Server 2012 R2 Automatic Maintenance with PSEXEC
After digging around and with help from my friend Kurt Teo from Melbourne, the solution I found was to disable it using the PSEXEC tool and this command.
NOTE: Please be cautious and use this procedure at your own risk: I did not test this on production servers, and stopping the task scheduler may also stop automatic Windows updates or other tasks, so please test before applying to production.
This is the ONLY known way to stop it from ever running:
- Download: PSEXEC – Microsoft Sysinternals
After downloading PSEXEC, open a Command Prompt with elevated permissions, and type:
psexec \%computername% -s schtasks /change /tn "MicrosoftWindowsTaskSchedulerMaintenance Configurator" /disable
(Use the path the where PSEXEC is located, or add it to your system path.)
Disabling Windows Server 2012 R2 automatic maintenance using PSEXEC. (Image: Daniel Petri)
Confirmation that the maintenance configurator in Windows Server 2012 R2 has been disabled. (Image: Daniel Petri)
If you’ve used PSEXEC to troubleshoot any other Windows Server 2012 frustrations, please add a comment to this post and share your experiences.