Skip to content

Tag: remove

[Powershell] Removing the NXLOG-agent without the Nagios management interface.

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.

[Veeam] Manually remove restore points

Veeam does not have a built-in function to remove restore points manually, it took me a while but after trying a lot of different ways and scripts I have found a way to do it. (Please note that this is a last resort, Veeam should clean-up old restore points by itself)

  1. Go to Backup & Replication -> Backups.
  2. Right-click the job you want to edit and click ‘Remove from configuration’ (Do not delete from disk!).
  3. Open the Windows Explorer and browse to the job’s folder in the backup repository.
  4. Delete the restore points you want to remove, and delete the .VBM file.
  5. Re-import the most recent .VBK file in the Veeam.
  6. Run the following script using the Veeam Powershell to generate a new .VBM file:
    #[Veeam.Backup.Core.CCredentilasStroreInitializer]::InitLocal() to work with Lin repository
    
    $backupName = Read-Host "Enter backup name for meta regeneration"
    
    Add-Type -Path "C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.Core.dll"
    [Veeam.Backup.Common.LogFactory]::InitializeConsoleLog()
    
    Try
    {
    $backup = [Veeam.Backup.Core.CBackup]::GetAll() | Where { $_.Name.Equals($backupName) } | Select -index 0
    
        if ($backup -eq $null)
          {
            throw ("There is no backup with specified name : " + $backupName)
          }
    
    $storageAccessor = [Veeam.Backup.Core.CStorageAccessorFactory]::Create($backup)
    
    [Veeam.Backup.Core.CCredentilasStroreInitializer]::InitLocal()
    
    
    
    $metaUpdater = New-Object Veeam.Backup.Core.CSimpleBackupMetaUpdater
    $metaEx = new-object Veeam.Backup.Core.CBackupMetaEx -ArgumentList $backup, $storageAccessor, $metaUpdater
    $metaEx.GenerateAndSave()
    
    $metaFilePath = $backup.GetMetaFilePath($storageAccessor.FileCommander)
    Write-Host "Successfully saved meta for backup $($backupName) on $($storageAccessor.Name) : $($metaFilePath)"
    }
    Catch
    {
    Write-Host $_.Exception.Message
    Write-Host $_.Exception.StackTrace
    Write-Host $_.Exception.InnerException.Message
    Write-Host $_.Exception.InnerException.StackTrace
    Break
    }
    
    $Reader = [System.IO.StreamReader] $metaFilePath 
    $MyString = $Reader.ReadToEnd();
    $Reader.Dispose();
    
    
    $removeString = 'LinkId="00000000-0000-0000-0000-000000000000"';
    $index = $MyString.IndexOf($removeString);
    $lengh = $removeString.Length;
    
    $start = $MyString.Substring(0, $index);
    $end  = $MyString.Substring($index + $lengh);
    
    $clean = $start + $end;
    
    
    
    $writer = [System.IO.StreamWriter] $metaFilePath
    $writer.WriteLine($clean);
    $writer.Close();
  7. Remove the imported backup from Veeam
  8. Re-scan the backup repository (Backup Infrastructure -> Backup Repositories)
  9. Go to the associated backup job and re-map the backup. You can do this by editing the job, going to the Storage-tab and click Map backup.

And that’s it! Now you’ve reclaimed the disk space you needed, removed corrupted backups, or whatever reason you had for removing the restore points.

Stefan van Bruggen - 2019