PowerShell script exchange
Post Reply
Leo0601
Enthusiast
Posts: 41
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Powershell script to uninstall Veeam 9.5

Post by Leo0601 »

Hello,

Anyone has powershell script to uninstall veeam 9.5 (Not clean uninstall - because we need existing database). Just a script to remove all the veeam components from control panel or registry through uninstall string.

I have tried with my script which is trying uninstall all the veeam components. But still some components are pending. How to remove all the veeam components through powershell script.

Regards
Leo.
HannesK
Product Manager
Posts: 14319
Liked: 2890 times
Joined: Sep 01, 2014 11:46 am
Full Name: Hannes Kasparick
Location: Austria
Contact:

Re: Powershell script to uninstall Veeam 9.5

Post by HannesK »

Hello,
Not clean uninstall - because we need existing database
if you uninstall VBR, then the SQL server stays installed. Meaning the existing configuration database is still available after uninstall of VBR.

The upgrade scripts on veeamhub.io have a part that also does the uninstall of the previous version (because an upgrade is uninstall / install in reality): https://github.com/VeeamHub/powershell/ ... UpgradeV10

https://helpcenter.veeam.com/docs/backu ... ml?ver=110 (unattended upgrade)

Best regards,
Hannes
Leo0601
Enthusiast
Posts: 41
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Powershell script to uninstall Veeam 9.5

Post by Leo0601 »

Hello Hannes,

W.r.t unattended upgrade for me its not working. I have used that same veeam upgrade script from the mentioned link (powershell-f26/automated-upgrade-from-9 ... 65286.html). I have already replied you can see. Developer of the script ask me raise a case with veeam support.

Already raised a case with Veeam but no luck. Might be our infra issue or something. So that's why I am manually taking veeam configuration back, then Uninstalling veeam 9.5, then Installing veeam 10 through powershell script and restoring the configuration backup.

Now I just need powershell script to uninstall the veeam 9.5 from control panel. Is it anyone written any script regarding that ?

Regards
Leo
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell script to uninstall Veeam 9.5

Post by oleg.feoktistov » 1 person likes this post

It's been a while since I had a lab with VBR v9.5 at hand, so it can take some time before I reply with the results.
Maybe somebody will share their thoughts quicker. Anyway, I'll post the outcome as soon as I finish tests. Thanks!
Leo0601
Enthusiast
Posts: 41
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Powershell script to uninstall Veeam 9.5

Post by Leo0601 »

Hi Oleg,

Thanks much. You have already help me to fix the some of the issues. I hope you will give me the solution for this as well.

I am waiting for your reply.

I look forward to hearing from you.

Regards
Leo.
Leo0601
Enthusiast
Posts: 41
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Powershell script to uninstall Veeam 9.5

Post by Leo0601 »

Hi Oleg,

I am waiting for your reply.

I have created the below script to uninstall Veeam from control panel and Remove from registry. But there is no luck. Since it not removing all the veeam components in one shot, I have to run the script 3 times and also it require reboot, I cant continue the uninstallation process silently without reboot, Since I am doing from WMIObject. I don't think so my script or way of doing is fine.

Can you please help me to fix it. I am looking forward to get the script from you.

Thanks in advance.

Regards
Leo.

Code: Select all


Function UninstallVeeam

{

write-host "Uninstalling Veeam...." -fore yellow

$app1 = Get-WmiObject -Class Win32_Product | Where-Object { 
    $_.Name -like "*Veeam*" 
}
$app1.Uninstall()

$VeeamServicePath = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\VeeamDeployerService"
if (Test-Path $VeeamServicePath){
Remove-Item -Path  $VeeamServicePath -Recurse
}

$VeeamBackupandReplication = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Veeam Backup & Replication"
if (Test-Path $VeeamBackupandReplication){
Remove-Item -Path  $VeeamBackupandReplication  -Recurse
}

write-host "Successfully Uninstalled Veeam" -fore green
}

UninstallVeeam

oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell script to uninstall Veeam 9.5

Post by oleg.feoktistov » 1 person likes this post

Hi Leo,

I managed to perform uninstallation of VBR v9.5 through WMI cmdlets without any issues using the script below:

Code: Select all

$veeamConsole = 'Veeam Backup & Replication Console'
$objects = Get-WmiObject -Class win32_product
$veeamComponents = $objects | where {$_.Name -like 'Veeam*' -and $_.Name -ne $veeamConsole}
foreach ($object in $veeamComponents) {
  Write-Output "Uninstalling $($object.Name)"
  $object.Uninstall()
}
Start-Sleep -Seconds 5

$console = $objects | where {$_.Name -eq $veeamConsole}
Write-Output "Uninstalling $($console.Name)"
$console.Uninstall() 
No restart prompt received whatsoever. Also, it appears that you need to uninstall VBR console the last. That's why I excluded it from the first search query in my script.

You can also use the script below to obtain uninstallation string for each component from the registry:

Code: Select all

 
$components = @(
 'Veeam Remote Tape Access Service'
)

function Uninstall-Component {
    $uninstall64 = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
    foreach($obj in  $uninstall64) {
        $displayName = $obj.GetValue("DisplayName")
        if ($displayName -contains $args[0]) {
            Write-Output "Uninstalling x64 components for $($args[0])"
            $uninstString = $obj.GetValue("UninstallString")
            foreach ($line in $uninstString) {
                $found = $line -match '(\{.+\}).*'
                If ($found) {
                    $appid = $matches[1]
                    Write-Output $appid
                    start-process "msiexec.exe" -arg "/X $appid /qb /norestart" -Wait
                }
            }
        }
    }
    $uninstall32 = Get-ChildItem "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
 
    foreach($obj in  $uninstall32) {
        $displayName = $obj.GetValue("DisplayName")
        if ($displayName -contains $args[0]) {
            Write-Output "Uninstalling x86 components for $($args[0])"
            $uninstString = $obj.GetValue("UninstallString")
            foreach ($line in $uninstString) {
                $found = $line -match '(\{.+\}).*'
                If ($found) {
                    $appid = $matches[1]
                    Write-Output $appid
                    start-process "msiexec.exe" -arg "/X $appid /qb /norestart" -Wait
                }
            }
        }
    }
  
}
foreach ($component in $components) {
Uninstall-Component $component
} 
However, this won't work on components, which don't have "msiexec.exe" piece in their uninstallation string values.
One of those components is VBR console.

Best regards,
Oleg
Leo0601
Enthusiast
Posts: 41
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Powershell script to uninstall Veeam 9.5

Post by Leo0601 »

Hi Oleg,

I would like to thank you for being patience. Your support has been most valuable. I sincerely appreciate your great effort. It means a lot. You have fixed some issues already.

Here I have one query, We are going uninstall Veeam components through your uninstallation string script. I am not able to start the script execute this script. May I know what I have to pass in $components which I have mentioned below, Inplace of "Veeam Remote Tape Access Service" what I have to exactly pass ? Where I have to take that information from my server. Its windows 2012 R2.

$components = @(
'Veeam Remote Tape Access Service'
)

I am looking forward to hear from you.

Thanks & Regards
Leo.
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell script to uninstall Veeam 9.5

Post by oleg.feoktistov » 1 person likes this post

Hi Leo,

You can get the list of the Veeam-related components installed with the same old wmi cmdlet and then add each component's name to an array:

Code: Select all

$components = @()
$veeamObjects = Get-WMIObject -Class win32_product | where {$_.Name -like 'Veeam*'}
foreach ($object in $veeamObjects) {
 $components += $object.Name
}
Then, just loop through each of the array member with the script I shared above. Also, sorry for misguidance about the uninstallation string not working for VBR console and else if msexec.exe is not a part of the uninstallation string value. It actually works, just make sure you uninstall VBR console the last. So, you might need to exclude VBR console from the components array and act on it later or run the script twice.

Hope it helps,
Oleg
Leo0601
Enthusiast
Posts: 41
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Powershell script to uninstall Veeam 9.5

Post by Leo0601 » 2 people like this post

Hi Oleg,

Thank you so much for your assistance. You showed your valuable efforts and given solution for my issue. Given thumbs-up for all your replies related to this post.

Your support has been invaluable. I would like to express my deep gratitude to you. I sincerely appreciate your great effort.

As you said I have modified your script and changed the logic like uninstalling the VBR console in the last. Its working perfectly. Thanks for the idea and your wonderful script.

I sincerely appreciate your great support. I'm grateful to you.

Regards
Leo.
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell script to uninstall Veeam 9.5

Post by oleg.feoktistov »

Thanks for your kind words. Glad I could help you!
Post Reply

Who is online

Users browsing this forum: Baidu [Spider], jeffkaplan and 19 guests