The scripts in this library come from a variety of sources, including partners and other third parties. While N-able performs initial testing on these scripts, we do not regularly or permanently monitor these scripts, and therefore, we cannot make any guarantees about third-party content. By downloading or using any of these scripts, you agree that they are provided AS IS without warranty of any kind and we expressly disclaim all implied warranties including warranties of merchantability or of fitness for a particular purpose. In no event shall N-able or any other party be liable for any damages arising out of the use of or inability to use these scripts.

N-able suggests as a best practice that scripts should be tested on non-production environments.

Patch Management Engine - (PME) Repair Script

Last Modified Date

5/3/2022 3:21 PM

Description

More info here: PME-REPAIR
This script was submitted to the cookbook by Ashley How at Healthcare Computing. (UK)

What is Repair-PME?

Repair-PME is a script provided to the community that repairs N-able Patch Management Engine (PME) used by N-able N-Central. If for any reason it becomes corrupt, fails an upgrade or installation process PME-Repair should be able to fix it in the most scenarios.

Why was Repair-PME created?

Repair-PME was created as I was getting frustrated with having to spend time trying resolve various issues where PME had broken and subsequently caused Patch Status v2 to become misconfigured in N-Central. Obviously having this in the misconfigured state is very bad as you cannot determine what's going on with patching. Please note is only designed to fix issues where PME is broken and reinstall is required to resolve. There may be cases where you will need to engage support to assist further. An example of an error that can be fixed with this tool.

What does Repair-PME do?

Repair-PME does the following with logic, error handling and event logging to operate as user-friendly as possible. Any errors during execution of the script will throw to PowerShell and will also be reported to the event log (Event ID 100).

  • Checks to ensure script is run elevated (as an administrator) to ensure all necessary actions can be performed.
  • Writes an application event log from source 'Repair-PME' with event ID 100 reporting script has started.
  • Gets operating system version, operating system architecture and PowerShell version.
  • Performs connectivity tests to destinations required for PME. Download of PMESetup will be obtained via HTTP instead of HTTPS if issues with HTTPS connectivity is detected.
  • Performs certificates test to HTTPS destination required for PME (sis.n-able.com). Test will be bypassed if issues with HTTPS connectivity is detected.
  • Checks if N-Central Agent is installed, reports status and compatibility with PME.
  • Checks if PME is already installed and reports status.
  • Checks if PME has had a recent install. If a recent install (such as an auto-update) has occured within the configured period (2 days) then script will bypass the update pending check below to allow a force install. This can be changed, see settings below for further information.
  • Checks if PME has an update pending and reports status. If an update is pending within the configured period (2 days) then script will be aborted. This can be changed, see settings below for further information.
  • Invokes Solarwinds Diagnostics Tool and silently saves the log capture to C:\ProgramData\SolarWinds MSP\Repair-PME\Diagnostic Logs. These logs can be given to Solarwinds support for further troubleshooting hopefully resolving any bugs to make future PME releases more robust.
  • Terminates any currently running instances of PMESetup, CacheServiceSetup, RPCServerServiceSetup and _iu14D2N or similar.
  • Stops the PME services called SolarWinds.MSP.PME.Agent.PmeService, SolarWinds.MSP.RpcServerService and SolarWinds.MSP.CacheService. If operation times out they will be forcefully terminated.
  • Cleanup cached files from C:\ProgramData\SolarWinds MSP\SolarWinds.MSP.CacheService and C:\ProgramData\SolarWinds MSP\SolarWinds.MSP.CacheService\cache.
  • Checks existing PME config and informs of possible misconfigurations (cache size, fallback to external sources).
  • Obtains, checks (SHA-256 Hash) and downloads (if required) the latest available version of PME from sis.n-able.com if not verified locally.
  • Silently installs PME (PME Agent, Cache Service and RPC Server Service) and saves the install logs to 'C:\ProgramData\SolarWinds MSP\Repair-PME'.
  • Checks and reports all PME services are installed and running post-installation.
  • Writes an application event log from source 'Repair-PME' with event ID 100 reporting script has ended.

Settings

As of release 0.1.9.0 there are two user changeable settings which can be found at the beginning of the script in the settings section.

  • $RepairAfterUpdateDays - Change this variable to number of days (must be a number!) to begin repair after new version of PME is released. Default is 2. Repair-PME will abort if an update is pending within this period.

  • $ForceRepairRecentInstallDays - Change this variable to number of days (must be a number!) within a recent install to allow a force repair. This will bypass the update pending check. Default is 2. Ensure this is equal to $RepairAfterUpdateDays.

Type

PowerShell

Category

Windows Configuration

Target OS

Windows 8/8.1;Windows 10;Windows Server 2012 / 2012R2;Windows Server 2016;Windows Server 2019

Compatible with N-central

Yes

N-central minimum version

12.2.0.274+

Compatible with RMM

Yes

Syntax

Can I use Repair-PME in an Automation Policy (AMP) within N-Central?

Yes, just add the code to a 'Run Powershell Script' object in Automation Manager, save the AMP as 'Repair-PME' and upload to your N-Central server. It is the recommended method of using this script via N-Central.

Can I use Repair-PME from PowerShell interactively or via N-Central?

Yes, if you wish to do so. Please be aware your execution policy is set to allow this to run though.

Can I use Repair-PME for self-healing within N-Central?

Yes, but if this is executed during the wait period (2 days by default) of when an update has been released but has yet to be installed the script will abort with an error as it is recommended this is done gracefully via the built-in update mechanism. The only exception to this is if an install has occured in the last 2 days. This is to account for situations where an auto-update does not complete succesfully. It is recommended this is used as self-healing in conjunction with Prejay Shah's 'Patch Status - PME' AMP.

Where can I get the latest version of Repair-PME?

https://github.com/N-able/ScriptsAndAutomationPolicies/blob/master/Repair-PME/Repair-PME.ps1

Output

None

Keywords

Patch, Patch management, PME, Fix, Repair

Related Content