Windows Server maintenance: updates, Defender and performance checks
This guide sets up a weekly and monthly maintenance routine for your Windows Server: applying updates on a schedule, checking Microsoft Defender and the firewall, and catching performance, disk and clock problems early with PowerShell commands, step by step.
The maintenance routine: weekly and monthly checks
Problems on Windows Server usually build up over time: a postponed restart, a C: drive that is slowly filling up, virus definitions that have not been updated for weeks. Hostimor virtual servers are an unmanaged service, so operating system maintenance is your responsibility (see the Service Scope and Support Terms). Add the table below to your calendar.
| Frequency | Check | Tool or command |
|---|---|---|
| Weekly | Pending updates and whether a restart is needed | Windows Update, the RebootRequired key with Test-Path |
| Weekly | Defender status, virus definition age and recent detections | Get-MpComputerStatus, Get-MpThreatDetection |
| Weekly | Critical errors in the System and Application logs | Get-WinEvent |
| Weekly | Free space on the C: drive | Get-PSDrive C |
| Monthly | Taking a snapshot, installing the monthly updates and a planned restart | Snapshots, Windows Update or sconfig |
| Monthly | Component store and temporary file cleanup | Dism.exe, cleanmgr |
| Monthly | CPU, memory and disk latency trends | Task Manager, resmon, Get-Counter |
| Monthly | Firewall profiles, RDP rules and Defender exclusions | Get-NetFirewallProfile, Get-MpPreference |
| Monthly | Time synchronization and the VMware Tools service | w32tm, Get-Service VMTools |
| Monthly | A sample restore from your backup | Your backup tool |
Run the commands in a PowerShell window running as administrator. Microsoft releases security updates on the second Tuesday of every month; scheduling your monthly maintenance a few days later gives time for any problematic update to become known.
Windows Update: apply updates on a schedule
Settings, sconfig and update history
On servers with the Desktop Experience, manage updates from the Windows Update section of the Settings app; on Windows Server 2016–2022 it is under Update & Security, on 2025 it is in the main menu, and on 2012 R2 it is in Control Panel. On the command line, type sconfig: the Windows Update settings option chooses automatic, download-only or manual mode, and the install updates option installs pending updates. Menu numbers vary between versions, so find the option by its name (see Microsoft's sconfig documentation). To see recent updates and whether a restart is pending:
$wu = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired'
$cbs = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending'
(Test-Path $wu) -or (Test-Path $cbs)
Get-HotFix | Sort-Object InstalledOn -Descending | Select-Object -First 5 HotFixID, Description, InstalledOnIf the third line returns True, there are updates waiting for a restart; do not leave it that way for long, because it can also block later updates from installing.
Active hours and planned restarts
Windows does not restart on its own for updates during its active hours. Set the active hours to cover your busy period, and plan restarts yourself. The task below restarts the server at 03:30 the next day with a one-minute warning:
# One-time restart task for 03:30 tomorrow
$when = (Get-Date).Date.AddDays(1).AddHours(3).AddMinutes(30)
$trigger = New-ScheduledTaskTrigger -Once -At $when
$action = New-ScheduledTaskAction -Execute 'shutdown.exe' -Argument '/r /t 60'
Register-ScheduledTask -TaskName 'Planli-Yeniden-Baslatma' -Trigger $trigger -Action $action -User 'SYSTEM' -RunLevel Highest -Force
Get-ScheduledTask -TaskName 'Planli-Yeniden-Baslatma' | Get-ScheduledTaskInfoAfter the server is back up, delete the task with Unregister-ScheduledTask -TaskName 'Planli-Yeniden-Baslatma' -Confirm:$false. You can also use the Restart Server tool in the client area: when VMware Tools is running, it restarts Windows cleanly; when it is not, it performs a hard reset. So check first that the VMTools service is running (see the power actions guide).
During a restart, the "Working on updates" screen can take a long time. Do not use Force Stop or Hard Reset at this stage; an interrupted update can keep the system from booting. RDP does not connect during this phase, so follow the progress with the VNC Console.
Take a snapshot before major updates
Before the monthly cumulative update or a new server role, take a restore point with the Snapshots tool. You can keep at most 2 snapshots at a time; snapshots grow over time and the disk cannot be expanded while one exists, so delete it once you have verified the update. A snapshot is not a substitute for a backup (see the snapshot guide).
Microsoft Defender and the firewall
Microsoft Defender Antivirus is built into Windows Server 2016 and later. It is not built into Windows Server 2012 R2, and the cmdlets below are not available there.
Status, definition updates and scans
Get-MpComputerStatus | Select-Object AMServiceEnabled, AntivirusEnabled, RealTimeProtectionEnabled, AntivirusSignatureLastUpdated, AntivirusSignatureAge, QuickScanEndTime
Update-MpSignature
Start-MpScan -ScanType QuickScan
Get-MpThreatDetection | Select-Object -First 10 InitialDetectionTime, ThreatID, ActionSuccess, Resources
Get-MpThreat | Select-Object ThreatName, SeverityID, IsActiveAntivirusEnabled and RealTimeProtectionEnabled should be True. AntivirusSignatureAge shows how many days old the virus definitions are; if it is more than a few days, check outbound HTTPS connectivity and the Windows Update service. In the Get-MpThreatDetection output, ActionSuccess shows whether remediation succeeded, and Get-MpThreat shows each threat's name and severity.
Add exclusions only when you need them
Large files that change often, such as database files, can slow scanning down, and the software vendor may recommend excluding certain folders. Windows Server 2016 and later already apply some exclusions automatically based on the installed roles. Add manual exclusions only when needed and keep their scope narrow; every excluded folder is a blind spot for malware.
# Only for a narrowly scoped folder you have a reason to exclude
Add-MpPreference -ExclusionPath 'C:\SQLData'
# List the current exclusions
Get-MpPreference | Select-Object -ExpandProperty ExclusionPath
# Remove it once it is no longer needed
Remove-MpPreference -ExclusionPath 'C:\SQLData'Attackers who take over a server often add Defender exclusions so their own files are not scanned. Review the exclusion list during your monthly maintenance; if you see an entry you do not recognize, follow the steps for a compromised server.
Firewall profiles
All three Windows Defender Firewall profiles, Domain, Private and Public, should be on. Rules are applied according to the profile of the connection; the second command shows which profile you are in:
Get-NetFirewallProfile | Format-Table Name, Enabled
Get-NetConnectionProfile | Format-Table InterfaceAlias, NetworkCategory
Get-NetFirewallRule | Where-Object Name -like 'RemoteDesktop*' | Format-Table Name, Enabled, Profile
# If a profile is off (check the RDP rules first):
Set-NetFirewallProfile -Profile Domain,Private,Public -Enabled TrueBefore turning on a profile that is off, make sure the Remote Desktop rules are enabled in that profile; if you get locked out, sign in through the VNC Console and fix the rule. To restrict RDP access by IP address, see the RDP security guide.
Performance checks: CPU, memory and disk
When something is slow, start with Task Manager (taskmgr): the Performance tab shows CPU, memory, disk and network usage, and the Details tab shows the processes. Resource Monitor (resmon) also shows which process writes to which file and connects to which address. To record and compare measurements, read the counters with PowerShell:
Get-Counter -Counter '\Processor(_Total)\% Processor Time', '\Memory\Available MBytes', '\LogicalDisk(C:)\% Free Space', '\PhysicalDisk(_Total)\Avg. Disk sec/Read' -SampleInterval 2 -MaxSamples 5As a rule of thumb, there is a bottleneck if processor time stays above 80–90 percent for a long time, if available memory drops below 10 percent of total RAM, or if disk read time constantly exceeds 0.020 seconds (20 ms); look at samples over several minutes, not a single reading.
Performance counter names are localized to the language of the operating system. On a Windows installation with a Turkish interface, the English counter paths above can fail with a "not found" error; in that case, take the local counter names from Performance Monitor (perfmon), or use the language-independent CIM queries below.
Get-CimInstance Win32_PerfFormattedData_PerfOS_Processor -Filter "Name='_Total'" | Select-Object PercentProcessorTime
Get-CimInstance Win32_OperatingSystem | Select-Object @{Name='FreeMB'; Expression={[math]::Round($_.FreePhysicalMemory / 1KB)}}, @{Name='TotalMB'; Expression={[math]::Round($_.TotalVisibleMemorySize / 1KB)}}
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 Name, Id, CPU, @{Name='RAM_MB'; Expression={[math]::Round($_.WorkingSet64 / 1MB)}}The CPU column does not show the current percentage but the total processor seconds used since the process started, so it is normal for a long-running service to be at the top. If resources are regularly not enough, consider tuning your application or a resource upgrade.
System health: disk, clock, logs and VMware Tools
Disk space
Get-PSDrive C shows used and free space. One of the biggest consumers of space on Windows is the component store, which keeps older update components (C:\Windows\WinSxS). Do not delete this folder by hand; clean it up with DISM:
Get-PSDrive C
Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore
Dism.exe /Online /Cleanup-Image /StartComponentCleanup
cleanmgr /sageset:1
cleanmgr /sagerun:1/AnalyzeComponentStore reports how much space can be reclaimed. /ResetBase frees more space but makes installed updates impossible to uninstall, so use it only deliberately. In Disk Cleanup, /sageset:1 lets you choose items and /sagerun:1 applies the selection. If space is still short, after a disk upgrade the C: drive is extended automatically while the server is running and VMware Tools is working; the disk cannot be expanded while a snapshot exists, and a virtual disk cannot be shrunk (see the resource upgrade guide).
Clock and time zone
A wrong clock leads to TLS certificate errors, scheduled tasks running at the wrong time and logs that cannot be compared:
tzutil /g
Set-TimeZone -Id 'Turkey Standard Time'
w32tm /query /status
w32tm /query /source
# If the source is "Local CMOS Clock":
w32tm /config '/manualpeerlist:time.windows.com,0x8' /syncfromflags:manual /update
Restart-Service w32time
w32tm /resyncIf w32tm /query /source shows Local CMOS Clock, the server is not synchronizing with a time source; the last three lines set one. Because outbound connections are allowed by default, no extra rule is needed for UDP 123. Set-TimeZone is not available in the default PowerShell version on Windows Server 2012 R2; set the time zone there with tzutil /s "Turkey Standard Time".
Event logs
The System and Application logs in Event Viewer (eventvwr.msc) hold the first trace of most problems. List the critical and error events of the last seven days and the unexpected shutdowns like this:
# Critical (1) and error (2) events from the last 7 days
Get-WinEvent -FilterHashtable @{LogName='System','Application'; Level=1,2; StartTime=(Get-Date).AddDays(-7)} -MaxEvents 30 -ErrorAction SilentlyContinue |
Format-Table TimeCreated, LogName, Id, ProviderName, LevelDisplayName -AutoSize
# Unexpected shutdowns and who initiated a restart
Get-WinEvent -FilterHashtable @{LogName='System'; Id=41,1074,6008} -MaxEvents 10 -ErrorAction SilentlyContinue |
Format-Table TimeCreated, Id, ProviderName, Message -WrapEvents 41 (Kernel-Power) and 6008 show that the server restarted without a clean shutdown, and 1074 shows which user or process initiated a restart. Update failures appear in the System log with the WindowsUpdateClient source and ID 20.
VMware Tools and backups
Most panel tools (safe shutdown, password reset, hostname, network and additional IP settings, disk expansion) work through VMware Tools. The VMTools service should be Running and Automatic; do not stop, disable or uninstall it. The in-server log of panel actions is in C:\Windows\Temp\wisecp-task.log:
Get-Service VMTools | Select-Object Name, DisplayName, Status, StartType
Get-Content C:\Windows\Temp\wisecp-task.log -Tail 30The last step of the routine is the backup. Unless your package explicitly includes one, backing up the server is your responsibility (see the Backup and Data Retention Policy). You can use the Windows Server Backup feature (Install-WindowsFeature Windows-Server-Backup) or the Windows version of restic; store the backup outside the server. For details, see the server backup strategy guide, and for your websites, the website backup plan.
Common problems
| Symptom | Likely cause | Fix |
|---|---|---|
| An update hangs at the same percentage or keeps failing | Corrupted system files or update cache | Apply the repair steps below; note the error code from the WindowsUpdateClient event |
| The update screen takes very long during a restart | A large cumulative update is being configured | Watch it in the VNC Console and wait; do not use Force Stop or Hard Reset |
| The C: drive filled up after updates | The component store and download cache have grown | /StartComponentCleanup and Disk Cleanup; a disk upgrade if needed |
TiWorker.exe uses high CPU for a long time | Windows Modules Installer is preparing updates | Let it finish; if it goes on for days, apply the repair steps |
MsMpEng.exe uses high CPU or disk | A Defender scan, or large files that change very often | Move the scheduled scan to a quiet hour with Set-MpPreference; add a narrowly scoped exclusion if needed |
The VMTools service is stopped | The service was stopped manually or cannot start | Start-Service VMTools; if it does not start, open a support ticket |
If updates keep failing, repair the system files first, and if the problem persists, reset the update cache. We recommend taking a snapshot before these steps:
# 1) Repair system files
Dism.exe /Online /Cleanup-Image /RestoreHealth
sfc /scannow
# 2) If the problem persists, reset the update cache
Stop-Service wuauserv, bits -Force
Rename-Item C:\Windows\SoftwareDistribution SoftwareDistribution.old
Start-Service bits, wuauservFrequently asked questions
Does this guide also apply to the Windows 10 Pro or Windows 11 Pro templates?
The Windows 10 Pro and Windows 11 Pro templates are meant for desktop use. Most of the Defender, firewall, performance and event log commands work there too; sconfig, however, exists only on Windows Server. Check on Microsoft's product lifecycle page that your version receives security updates; support for Windows Server 2012 R2 and Windows 10 has ended. If you are unsure which system to choose, see Linux or Windows server.
Should I install updates automatically or manually?
On a production server, a good balance is to download updates automatically and install and restart during your own maintenance window: security holes do not stay open for long, and the server does not restart at an unexpected moment. Do not let updates pile up for more than a month.
Should I install a separate antivirus alongside Defender?
For most servers, Defender is a sound starting point. If you install another antivirus, do not run two real-time scanners together: on Windows Server, Defender does not always disable itself when another product is installed, so put it into passive mode or remove it as the product's guidance describes.
Related articles
Thanks for your feedback!