CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 23:48:08 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=da5964dd60ce280f19afe1a30a256f6ef70efde23d47e9984533a52f7a3a6eb5a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%229cBapzQKfksYwpBhxBUB_-vLSqZHCKoi%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d23f1c6f0195be-BLR
NinjaMigration.ps1 - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .\On-MachineMigration.ps1 -Uninstall -Cleanup -ReinstallUri "<Ninja MSI URL>"
- #>
- param (
- [Parameter(Mandatory = $false)]
- [switch]$DelTeamViewer = $false,
- [Parameter(Mandatory = $false)]
- [switch]$Cleanup,
- [Parameter(Mandatory = $false)]
- [switch]$Uninstall,
- [Parameter(Mandatory = $true)]
- [string]$ReinstallUri,
- [Parameter(Mandatory = $false)]
- [switch]$ShowError
- )
- # Ensure admin
- $CurrentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
- if (!($CurrentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator))) {
- Write-Output 'Restarting as admin...'
- Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" -DelTeamViewer:$DelTeamViewer -Cleanup:$Cleanup -Uninstall:$Uninstall -ReinstallUri `"$ReinstallUri`" -ShowError:$ShowError" -Verb RunAs
- exit
- }
- $ErrorActionPreference = if ($ShowError) { 'Continue' } else { 'SilentlyContinue' }
- Write-Progress -Activity "Running Ninja Removal Script" -PercentComplete 0
- # Registry paths
- if ([System.Environment]::Is64BitOperatingSystem) {
- $ninjaPreSoftKey = 'HKLM:\SOFTWARE\WOW6432Node\NinjaRMM LLC'
- $uninstallKey = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
- $exetomsiKey = 'HKLM:\SOFTWARE\WOW6432Node\EXEMSI.COM\MSI Wrapper\Installed'
- } else {
- $ninjaPreSoftKey = 'HKLM:\SOFTWARE\NinjaRMM LLC'
- $uninstallKey = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
- $exetomsiKey = 'HKLM:\SOFTWARE\EXEMSI.COM\MSI Wrapper\Installed'
- }
- $ninjaSoftKey = Join-Path $ninjaPreSoftKey -ChildPath 'NinjaRMMAgent'
- $ninjaDataDir = Join-Path -Path $env:ProgramData -ChildPath "NinjaRMMAgent"
- $ninjaDir = ''
- # Try registry first
- $ninjaDirRegLocation = Get-ItemPropertyValue -Path $ninjaSoftKey -Name Location -ErrorAction SilentlyContinue
- if ($ninjaDirRegLocation -and (Test-Path "$ninjaDirRegLocation\NinjaRMMAgent.exe")) {
- $ninjaDir = $ninjaDirRegLocation
- }
- # Fallback to service path
- if (-not $ninjaDir) {
- $servicePath = (Get-WmiObject -Class win32_service -Filter "Name = 'NinjaRMMAgent'").PathName
- if ($servicePath) {
- $ninjaDirService = ($servicePath | Split-Path).Replace('"', '')
- if (Test-Path "$ninjaDirService\NinjaRMMAgentPatcher.exe") {
- $ninjaDir = $ninjaDirService
- }
- }
- }
- # Uninstall Ninja
- if ($Uninstall) {
- Start-Process -FilePath "$ninjaDir\NinjaRMMAgent.exe" -ArgumentList "-disableUninstallPrevention", "NOUI" -Wait
- $productID = (Get-WmiObject -Class Win32_Product -Filter "Name = 'NinjaRMMAgent'").IdentifyingNumber
- if ($productID) {
- Start-Process -FilePath "msiexec.exe" -ArgumentList "/x $productID /quiet /norestart" -Wait
- }
- }
- # Cleanup files and registry
- if ($Cleanup) {
- $service = Get-Service -Name "NinjaRMMAgent" -ErrorAction SilentlyContinue
- if ($service) {
- Stop-Service -Name $service -Force
- sc.exe DELETE $service
- }
- foreach ($path in @($ninjaDir, $ninjaDataDir)) {
- if (Test-Path $path) {
- Remove-Item -Path $path -Recurse -Force
- }
- }
- foreach ($keyPath in @($ninjaPreSoftKey, $uninstallKey, $exetomsiKey)) {
- if (Test-Path $keyPath) {
- Remove-Item -Path $keyPath -Recurse -Force
- }
- }
- }
- # Remove TeamViewer
- if ($DelTeamViewer) {
- Get-Process -Name "teamviewer*" -ErrorAction SilentlyContinue | Stop-Process -Force
- $teamViewerPaths = @("${env:ProgramFiles(x86)}\TeamViewer\uninstall.exe", "${env:ProgramFiles}\TeamViewer\uninstall.exe")
- foreach ($path in $teamViewerPaths) {
- if (Test-Path $path) {
- Start-Process -FilePath $path -ArgumentList "/S" -Wait
- }
- }
- Remove-Item -Path "HKLM:\SOFTWARE\TeamViewer" -Recurse -Force -ErrorAction SilentlyContinue
- Remove-Item -Path "HKLM:\SOFTWARE\WOW6432Node\TeamViewer" -Recurse -Force -ErrorAction SilentlyContinue
- }
- # Download MSI
- $MsiDest = "C:\ProgramData\ninjaone.msi"
- try {
- Write-Output "Downloading MSI from $ReinstallUri..."
- [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]'Tls12,Tls13'
- (New-Object Net.WebClient).DownloadFile($ReinstallUri, $MsiDest)
- } catch {
- Write-Error "Failed to download MSI: $_"
- exit 1
- }
- # Write reinstall script with proper quoting
- $InstallScriptPath = "$env:TEMP\NinjaReinstall.ps1"
- $InstallScriptContent = @'
- Start-Transcript "$env:TEMP\NinjaReinstallLog.txt"
- $msi = "C:\ProgramData\ninjaone.msi"
- $args = "/i `"$msi`" /qn /norestart"
- Start-Process msiexec.exe -ArgumentList $args -Wait
- "NinjaOne Agent installed successfully at $(Get-Date)" | Out-File -Append "$env:TEMP\NinjaReinstallStatus.txt"
- Stop-Transcript
- '@
- Set-Content -Path $InstallScriptPath -Value $InstallScriptContent -Force
- # Register scheduled task
- $TaskName = "ReinstallNinjaOne"
- if (Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue) {
- Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false
- }
- $Action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$InstallScriptPath`""
- $Trigger = New-ScheduledTaskTrigger -Once -At ((Get-Date).AddMinutes(1))
- $Principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
- Register-ScheduledTask -TaskName $TaskName -Action $Action -Trigger $Trigger -Principal $Principal
- Write-Output "Scheduled Ninja reinstall in 1 minute."
- # Optional error logging
- if ($ShowError) {
- $error | Out-File -FilePath "$env:TEMP\NinjaRemovalScriptError.txt"
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
β
Make $2500 in 20 minutesβββ R
JavaScript | 3 sec ago | 0.25 KB
-
π EASY MONEY GUIDE β
Working
JavaScript | 4 sec ago | 0.24 KB
-
β
Make $2500 in 20 minutesβββ 3
JavaScript | 7 sec ago | 0.25 KB
-
π Swapzone +37% glitch β R
JavaScript | 12 sec ago | 0.25 KB
-
π ChangeNOW Exploit
JavaScript | 14 sec ago | 0.24 KB
-
β
β Make huge profits on trading ββ 8
JavaScript | 21 sec ago | 0.25 KB
-
π EASY MONEY GUIDE β
Working
JavaScript | 26 sec ago | 0.24 KB
-
ββ
Marketplace Glitch β
Working β
NEVER SEEN...
JavaScript | 30 sec ago | 0.25 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand