Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Selva Arun
Mega Sage
Mega Sage

 

🚀 MID Server Pre-Upgrade Readiness Checklist

Automated PowerShell Validation Script - Prevent Upgrade Failures Before They Happen

KB0596459 Production Tested All Versions


🔥 The Problem That Inspired This Solution

Real Production Incident - October 2025: During a routine family upgrade at my organization, multiple production MID Servers failed to upgrade, causing Discovery operations to halt and CMDB data collection to stop. The failures resulted in 4+ hours of troubleshooting, emergency intervention, and a Severity 1 (Sev1) case with ServiceNow Support.

What Went Wrong:

  • Service Account Permissions Issue: The MID Server service account did not have permissions to restart services during the upgrade process, causing the upgrade to fail
  • PowerShell Execution Policy Issue: All PROD MID Servers showed "null (vnull)" capabilities after attempting to upgrade, preventing any Windows-based discovery or operations
  • No Pre-Validation: We had no way to check if MID Servers were ready for upgrade before the automatic upgrade initiated
  • Reactive Approach: We only discovered issues AFTER the upgrade failed, when it was too late to prevent downtime
  • Manual Troubleshooting: Spent hours checking each MID Server manually using ServiceNow KB0596459 while on a Sev1 call with ServiceNow Support

Root Cause Analysis:

After extensive investigation with ServiceNow Support using KB0596459 ("Troubleshoot MID Server upgrade issues"), we identified TWO critical issues:

  1. Service Account Permissions (PROD): The service account running the MID Server did not have sufficient permissions to restart Windows services, which is required during the upgrade process. This caused the upgrade to fail in production.
  2. PowerShell Execution Policy (DEV): DEV MID Servers had PowerShell execution policy set to "Restricted", which prevented capabilities from downloading during the upgrade process, resulting in "null (vnull)" capabilities.

🎫 Severity 1 Case Outcome: ServiceNow Support confirmed these were known upgrade failure scenarios documented in KB0596459, but there was no proactive validation tool available to identify these issues before the upgrade.

The Realization:

If we had a way to validate MID Server prerequisites BEFORE the upgrade, we could have:

  • Identified the service account permission issue in advance
  • Identified the PowerShell policy issue in DEV
  • Fixed both issues during a planned maintenance window
  • Avoided 4+ hours of production downtime
  • Prevented the Sev1 case with ServiceNow Support
  • Saved thousands of dollars in emergency support costs

The Impact:

Impact Area Consequence
Discovery Operations All Windows-based discovery halted for 4+ hours
CMDB Data Collection No updates to Configuration Items during downtime
Service Catalog Windows provisioning workflows failed
Event Management Windows event monitoring stopped
Support Resources ⚠️ Required Sev1 engagement with ServiceNow
Staff Hours ⚠️ 4+ hours of emergency troubleshooting

💡 The Solution: I created this comprehensive PowerShell validation script to test ALL known MID Server upgrade failure scenarios from KB0596459 BEFORE the upgrade happens. This script specifically checks for the exact issues we encountered:

  • Service account permissions (prevents restart failures)
  • PowerShell execution policy (prevents "null (vnull)" capabilities)
  • Network connectivity (prevents download failures)
  • File system access (prevents deletion errors)
  • Configuration validation (prevents authentication failures)

Validation Results: This script has been tested and validated in production healthcare environment. When I ran it on our DEV MID Server (SNOWMIDDEV01) in November 2025, it completed successfully in 3 seconds and identified all prerequisites were met, giving us confidence to proceed with upgrades.

SelvaArun_0-1763410151422.jpeg

 


What This Script Does

This automated PowerShell script performs a comprehensive pre-upgrade validation of your MID Server by testing for the 5 most common upgrade failure scenarios documented in ServiceNow KB0596459:

KB0596459 Failure What We Check Impact if Not Fixed
"Service account lacks permissions" Service account has FullControl on MID Server folder and can restart services 🔴 Upgrade fails when trying to restart services (Our Oct 2025 PROD incident)
"The MID Server was unable to download" Network connectivity to both your ServiceNow instance and install.service-now.com on port 443 🔴 Upgrade will hang at "downloading" phase
"Unable to delete file" Service account has FullControl permissions on MID Server folder 🔴 Upgrade will fail when trying to replace files
"User is unable to authenticate" Username and password configured in config.xml 🔴 MID Server cannot communicate with instance
"FileNotFoundException: Access is denied" Application Experience service status (Windows) 🔴 Upgrade fails with access denied errors
"ConnectTimeoutException" Network latency and firewall rules 🔴 Timeouts during upgrade process

📚 Based on Official Documentation:

  • ServiceNow KB0596459: "Troubleshoot MID Server upgrade issues"
  • ServiceNow KB0713557: "How to manually restore or upgrade a MID Server after a failed auto-upgrade"

Additional Checks (Beyond KB0596459):

  • Service Account Type: Ensures not running as LocalSystem (limited permissions) - validates the account has proper domain permissions to restart services during upgrade
  • PowerShell Execution Policy: Prevents "null (vnull)" capabilities issue (our October 2025 DEV incident)
  • System Resources: Validates sufficient disk space (10GB+) and RAM (4GB+)
  • Agent Log Analysis: Scans for existing error patterns that indicate problems

💡 Critical Lesson Learned: Our October 2025 production incident taught us that service account permissions are often overlooked but CRITICAL for successful upgrades. The MID Server process needs to restart itself during upgrades, and without proper permissions, the upgrade will fail silently. This script specifically validates that the service account has FullControl on the MID Server directory, which includes the ability to restart services.


📥 Download & Use the PowerShell Script

⚠️ IMPORTANT: Before Running the Script

  1. 📎 Download the attached file: MIDServer-PreUpgrade-Validation (at the bottom of this post)
  2. ✏️ Edit lines 23-24 with YOUR MID Server details:
    • Line 23: $MIDServerName = "SNOWMIDPRD01"Change to YOUR MID name
    • Line 24: $MIDServerPath = "D:\ServiceNow\MID Server..."Change to YOUR path
  3. 💾 Save the file
  4. Run PowerShell as Administrator
  5. ▶️ Execute: .\MIDServer-PreUpgrade-Validation.ps1

🔍 Need Help Finding Your MID Server Details?

To find your MID Server service name:

Get-Service | Where-Object { $_.Name -like "*MID*" } | Format-Table Name, DisplayName, Status -AutoSize

Example output:

Name                    DisplayName                              Status
----                    -----------                              ------
snc_mid_SNOWMIDPRD01   ServiceNow MID Server_SNOWMIDPRD01       Running

Extract the MID Server name: From snc_mid_SNOWMIDPRD01, use SNOWMIDPRD01

To find your installation path:

Get-ChildItem -Path "C:\" -Filter "*MID*" -Directory -Recurse -ErrorAction SilentlyContinue

Key Features:

  • 100% Safe: Read-only operations, no changes made to your system
  • Fast: Complete validation in 30-60 seconds
  • Comprehensive: Tests 12 critical checkpoints
  • Clear Output: Color-coded results (Green=Pass, Yellow=Warning, Red=Critical)
  • GO/NO-GO Decision: Clear recommendation at the end
  • Detailed Results: Table view of all test results
  • Actionable Recommendations: Specific fixes for any failures

Production Test Results

Environment: Healthcare Production Environment
MID Server: SNOWMIDDEV01
Date Tested: November 17, 2025
OS: Windows Server
Service Account: Domain Service Account

Metric Result
Total Tests 12
Passed 11
⚠️ Warnings 1
Critical Failures 0
️ Validation Time 3 seconds
Final Decision GO - Safe to Upgrade

Detailed Test Results:

Category Test Name Status Details
Service Account Type PASS Running as: Domain Service Account
Service Status PASS Service is running
Permissions File Access PASS Has FullControl
PowerShell Execution Policy PASS Policy: Unrestricted
Resources Disk Space PASS 38.96 GB free
Resources Memory PASS 16 GB RAM
Network Instance PASS Connected to ServiceNow instance
Network Install Server PASS Connected to install.service-now.com
Services Application Experience WARNING Service not found (non-critical)
Logs Error Patterns PASS No known errors found
Config Username PASS Username configured
Config Password PASS Password configured

💪 Benefits of Using This Script

Proactive vs. Reactive:

Without This Script (Reactive) With This Script (Proactive)
Discover issues AFTER upgrade fails Identify issues BEFORE upgrade starts
4+ hours of emergency troubleshooting 30-60 seconds of validation
Production downtime during business hours Fix during planned maintenance window
Manual checking of each potential issue Automated testing of all known issues
Uncertainty about root cause Clear identification of problems

Time Savings:

  • Manual validation (KB0596459 method): 30-45 minutes per MID Server
  • Automated script: 30-60 seconds per MID Server
  • Time saved: ~40 minutes per MID Server
  • For 10 MID Servers: ~6.5 hours saved

Risk Reduction:

  • Prevents production downtime
  • Validates BEFORE automatic upgrade triggers
  • Tests all KB0596459 documented failure scenarios
  • Provides clear GO/NO-GO decision
  • Gives specific recommendations for fixes

📅 When to Use This Script

Recommended Schedule:

  1. Before Quarterly Patch Upgrades (QPP): Run 1-2 weeks before the scheduled patch to identify any issues in advance
  2. Before Major Version Upgrades: Run as part of your pre-upgrade checklist
  3. After Infrastructure Changes: Run after any changes to:
    • Windows Server patches/updates
    • Network configuration changes
    • Firewall rule modifications
    • Service account password changes
  4. New MID Server Deployment: Run immediately after installation to verify configuration
  5. Troubleshooting: Run when MID Server is showing issues to quickly identify problems
  6. Regular Health Checks: Run monthly as part of routine maintenance

⚠️ Limitations & Important Notes

What This Script Does NOT Do:

  • Does not perform the actual upgrade
  • Does not modify any system settings
  • Does not restart services
  • Does not test application-specific functionality
  • Does not guarantee 100% upgrade success (tests known issues only)

Requirements:

  • Must run on the actual MID Server host machine (not remotely)
  • Requires PowerShell as Administrator
  • Requires access to MID Server installation directory
  • Network connectivity must be available for testing

Platform Support:

  • Windows Server: 2012 R2, 2016, 2019, 2022
  • PowerShell: 3.0+ (5.1+ recommended)
  • ServiceNow: All versions (tests are version-agnostic)
  • Linux MID Servers: Not supported (Windows-specific script)

🔧 Troubleshooting Common Issues

Issue 1: "Service not found"

Solution: ServiceNow uses different service naming formats. Find your service name:

Get-Service | Where-Object { $_.Name -like "*MID*" } | Format-Table Name, DisplayName, Status

Common formats:

  • snc_mid_MIDSERVERNAME (most common)
  • ServiceNow MID Server_MIDSERVERNAME
  • MIDServerMIDSERVERNAME

Issue 2: "Execution policy prevents script"

Solution: Run PowerShell as Administrator and execute:

Set-ExecutionPolicy Bypass -Scope Process -Force

Issue 3: "Path not found"

Solution: Verify your MID Server installation path:

Get-ChildItem -Path "C:\" -Filter "*MID*" -Directory -Recurse -ErrorAction SilentlyContinue

🚀 Future Enhancements

Based on community feedback, I'm planning to add:

  • 🔄 Batch validation: Test multiple MID Servers from a central location
  • 📧 Email reports: Automatic email notifications with results
  • 📊 Historical tracking: Store results in a database for trending
  • 🔌 ServiceNow integration: Push results directly to ServiceNow tables
  • 🐧 Linux version: Bash script for Linux-hosted MID Servers
  • 📅 Scheduled automation: Windows Task Scheduler integration
  • 🎨 HTML report generation: Professional reports for management

Want to contribute? Connect with me on LinkedIn or through the NowDivas YouTube channel!


Conclusion

After experiencing a painful production MID Server upgrade failure in October 2025, I created this comprehensive pre-upgrade validation script to prevent similar issues from happening again. This script has been tested in production healthcare environment and successfully identified configuration issues before they could cause upgrade failures.

Key Takeaways:

  • Prevention is better than recovery: Spend 60 seconds validating instead of 4+ hours troubleshooting
  • Automate manual processes: Let the script check what would take 45 minutes manually
  • Base on official documentation: All tests derived from ServiceNow KB0596459
  • Test in production first: Validate in DEV/TEST before rolling to PROD
  • Share with the community: Help others avoid the same problems

This script is free to use and modify! If you find it helpful, please share your feedback and results in the comments below. Let's make MID Server upgrades smoother for everyone in the ServiceNow community!


📣 Help the Community!

If this script helped you prevent an upgrade failure or saved you time, please:

  • Mark this post as "Helpful" so others can find it
  • Share your test results in the comments
  • Report any issues or suggestions for improvements
  • Subscribe to NowDivas on YouTube for more ServiceNow content

Together, we can make MID Server upgrades less painful for everyone! 💪


📬 About the Author

Selva Arun (Senthil Meena)
ServiceNow Developer | ITOM/ITSM Specialist | Healthcare Industry
ServiceNow Rising Star 2024, 2025 | Knowledge 2024, 2025 Speaker
Co-founder: NowDivas YouTube Channel (with ServiceNow MVP Kristen Dettman)

🎥 YouTube: NowDivas
💼 LinkedIn: Connect for ServiceNow discussions
🎤 Speaking: Knowledge Conferences | World Forum presentations


📎 DOWNLOAD THE SCRIPT

Attached to this post:

  • MIDServer-PreUpgrade-Validation.ps1 - Complete PowerShell script (production-tested)
  • TestResults-Screenshot.png - Example output showing successful validation

Remember: Update lines 23-24 with YOUR MID Server details before running!

This script is based on real production experience and provided as-is for the ServiceNow community. Always test in non-production environments first!

Tags: MID Server | Pre-Upgrade | Validation | PowerShell | KB0596459 | Automation | ITOM | Best Practices | Upgrade Checklist | Windows | Discovery | CMDB

Comments
Christopher Hub
Tera Guru

Great job on this article!  Real-world symptom and resolution is my favorite topic. It would be amazing to bake this into something that could be executed remotely, but until then this super helpful.

Version history
Last update:
2 hours ago
Updated by:
Contributors