US English (US)
GB English (UK)

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Create ticket
English (US)
US English (US)
GB English (UK)
  • Home
  • Migration Agent

Clean uninstall of PowerSyncPro Migration Agent

Written by Conrad Murray

Updated at May 26th, 2025

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Getting Started
  • FAQs
  • API Documentation
  • Integrations
  • Migration Agent
  • Directory Synchronisation
  • Remote DC agent
  • Remote Password Sync Agent
  • Install and Configure
  • Support
  • Complex Expressions
+ More

There may be times where you need or want a complete uninstall of PowerSyncPro Migration Agent.  The following script will achieve this for you.  You can use this script stand-alone, or incorporate it into your software deployment tools and also Intune as a Platform Script under Scripts and remediations.

It will:

Check for the presence of PowerSyncPro

  • Stop the Service
  • Find the correct UninstallString
  • Uninstall PowerSyncPro Migration Agent
  • Delete the associated ProgramData directory
  • Delete the associated PowerSyncPro Registry Keys
  • Write a txt Log in c:\ProgramData
  • Write entries to the Windows Event Log
$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
}

 

 

thorough removal uninstaller

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • I've configured an SSL certificate in PowerSyncPro but my browser is not HTTPS
  • Prevent Migration Agent uninstall when deployed from Intune
  • Migration Agent is not starting or registering on a device

Subscribe to Newsletter

Drop your email in the box below to sign up. We promise to keep our updates relevant and useful – and we’ll never share your details.

PowerSyncPro is the ultimate product for easing the pain and frustration during mergers, acquisitions, divestitures, and consolidations.

Terms & Conditions

  • FAQs
  • Privacy Policy
  • Cookies
  • Anti Slavery Notice

PowerSyncPro

  • Case Studies
  • Contact sales
  • Meet the Team
  • EULA

Get Connected

Room 73, Wrest House, Wrest Park, Silsoe, Bedford, England, MK45 4HR
info@powersyncpro.com

Twitter Youtube Linkedin

Knowledge Base Software powered by Helpjuice

Expand