I made this script at the request of a colleague, who needed a quick way to remove the NXLOG-agent without having to resort to the management interface (which was unavailable).
<#
.Description
Script for the removal of the NXLOG agent without the use of the Nagios management interface.
Current Version: 1.0
Changelog:
----------------
v1.0: First version, ready for use
By: Stefan van Bruggen <info@svanbruggen.nl>
For: de Koning B.V <svbruggen@koning-ict.nl
#>
## Define the path where the key should be located and start a recursive search
## The script only looks for a registry key containing the right display name and publisher, and selects the LocalPackage property.
$inst = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\* -Recurse | Get-ItemProperty |
Where-Object {$_.DisplayName -like 'NXLOG-CE' -and $_.Publisher -like 'nxsec.com' -and $_.Publisher -ne '' } |
Select-Object LocalPackage -ExpandProperty LocalPackage
## Silent install of the package, required for the next step
Start-Process $inst -arg '/q' -Wait
## Silent uninstall of the agent
Start-Process "msiexec.exe" -arg "/X $inst /qn" -Wait
This script could also be modified quite easily to run on a remote computer by adding the following at the beginning of the script:
$PC='SRV-NAME-01'
Invoke-Command -ComputerName $PC -ScriptBlock {
In this case, don’t forget to add a } in line 21.