Skip to content
  • There are no suggestions because the search field is empty.

Clean uninstall of PowerSyncPro Migration Agent

Completely remove the PowerSyncPro Migration Agent by uninstalling the software, deleting registry keys, services, and leftover program data.

Use this script to perform a complete uninstall of PowerSyncPro Migration Agent — whether you are decommissioning a workstation, cleaning up a test environment, or rolling back a deployment. Run it stand-alone, incorporate it into your software deployment tools, or deploy it via Intune as a Platform Script under Scripts and Remediations.

The script performs the following actions in order:

  1. Checks for the presence of PowerSyncPro Migration Agent
  2. Stops the service
  3. Finds the correct UninstallString
  4. Uninstalls PowerSyncPro Migration Agent
  5. Deletes the associated ProgramData directory
  6. Deletes the associated PowerSyncPro registry keys
  7. Writes a .txt log to C:\ProgramData
  8. Writes entries to the Windows Event Log

Before running the script, ensure you have:

  • Administrator privileges on the target machine
  • PowerShell execution policy set to allow script execution (for example, RemoteSigned or Bypass)

The uninstall script

Copy the PowerShell script below and save it as a .ps1 file (for example, Uninstall-PowerSyncProAgent.ps1). Run it with administrator privileges, either directly or via your software deployment tool or Intune as a Platform Script under Scripts and Remediations.

$RegPath = 'HKLM:\SOFTWARE\Declaration Software\'
$UninstallKeyPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
$ServiceName = 'PowerSyncPro Migration Agent'
$AppName = 'PowerSyncPro Migration Agent'
$AppDataPath = 'C:\ProgramData\Declaration Software\'
$LogFile = "C:\ProgramData\PowerSyncProCleanup.log"
$EventSource = "Intune PowerSyncPro Cleanup"

function Log-Message {
    param (
        [string]$Message,
        [string]$EventType = "Information"
    )

    $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
    $logEntry = "$timestamp - $Message"

    # Write to file
    Add-Content -Path $LogFile -Value $logEntry

    # Attempt to log to Windows Event Log
    try {
        if (-not [System.Diagnostics.EventLog]::SourceExists($EventSource)) {
            New-EventLog -LogName Application -Source $EventSource -ErrorAction SilentlyContinue
        }
        Write-EventLog -LogName Application -Source $EventSource -EntryType $EventType -EventId 1000 -Message $Message
    } catch {
        # If we can't write to event log (common in Intune SYSTEM context), just skip
    }
}

# Begin script
Log-Message "Starting PowerSyncPro cleanup..."

# Only proceed if the key exists
if (Test-Path $RegPath) {
    try {
        # Stop service if it exists
        $svc = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
        if ($svc) {
            Stop-Service -Name $ServiceName -Force -ErrorAction Stop
            Log-Message "Service '$ServiceName' stopped successfully."
        } else {
            Log-Message "Service '$ServiceName' not found." -EventType "Warning"
        }

        # Look for the uninstall string
        $UninstallKey = Get-ChildItem $UninstallKeyPath |
            Where-Object { $_.GetValue('DisplayName') -eq $AppName }

        if ($UninstallKey) {
            $UninstallString = $UninstallKey.GetValue('UninstallString')
            if ($UninstallString) {
                $cmd = "$UninstallString /norestart /quiet"
                Log-Message "Uninstalling: $cmd"
                Start-Process -FilePath "cmd.exe" -ArgumentList "/c $cmd" -Wait
                Log-Message "Uninstallation completed."
            } else {
                Log-Message "Uninstall string not found." -EventType "Warning"
            }
        } else {
            Log-Message "Uninstall key not found in registry." -EventType "Warning"
        }

        # Remove registry key
        Remove-Item -Path $RegPath -Recurse -Force -ErrorAction Stop
        Log-Message "Registry key '$RegPath' deleted."

        # Remove application data folder
        if (Test-Path $AppDataPath) {
            Remove-Item -Path $AppDataPath -Recurse -Force -ErrorAction Stop
            Log-Message "AppData folder '$AppDataPath' deleted."
        } else {
            Log-Message "AppData folder '$AppDataPath' not found." -EventType "Warning"
        }

        # Final check
        if (-not (Test-Path $RegPath)) {
            Log-Message "Cleanup successful. Exiting with code 0."
            exit 0
        } else {
            Log-Message "Registry key still exists. Cleanup incomplete." -EventType "Error"
            exit 1
        }

    } catch {
        Log-Message "An error occurred: $_" -EventType "Error"
        exit 1
    }
} else {
    Log-Message "Registry key not found. No action taken."
    exit 0
}