PowerShell script exchange
Post Reply
quinnvanorder
Influencer
Posts: 15
Liked: 16 times
Joined: Jan 31, 2019 2:25 am
Full Name: Quinn Van Order
Location: Seattle WA
Contact:

Mass Upgrade to 9.5u4

Post by quinnvanorder » 10 people like this post

Hey All,

I have seen dead forum posts in the past asking how to mass update Veeam with command line. As we maintain hundreds of veeam instances, doing the upgrade manually was not an option. Below is the solution we have created. Please chime in if anything here could be improved. One note in the code examples I provided. We utilize Kaseya to manage our devices, and its scripting engine has limitations. Particularly in that powershell, to be reliably used must be invoked through command line, and it heavily encourages massive gross one line commands. I apologize for some of the code spaghetti coming.

First problem: As documented here ( https://helpcenter.veeam.com/docs/backu ... l?ver=95u4 ), upgrading via command line is not an option. It must be uninstalled, and then installed. Not cool, but manageable.

Second problem: The documentation on how to install Veeam in unattended mode is functionally 100% incorrect. ( https://helpcenter.veeam.com/docs/backu ... l?ver=95u4 )
From having undocumented required MSI flags, to not mentioning huge pieces of what is needed, it took a lot of time to get a solution working.

Now let's jump into it!

1 - For our solution, Kaseya's native unpack functionality does not play nice with ISO's, so we extracted the ISO and repackaged it as a zip on dropbox. The first portion of the script creates a working directory and places both the zip and our licence file in said directory. The zip is then unpacked. As that code has our own links in it, I will not provide it.

2 - Backup the config of veeam in case it breaks.

Code: Select all

powershell.exe -nologo -executionpolicy bypass -noprofile -command "Add-PSSnapin VeeamPSSnapin; Start-VBRConfigurationBackupJob"
3 - Stop all running jobs cleanly.

Code: Select all

powershell.exe -nologo -executionpolicy bypass -noprofile -command "Add-PSSnapin VeeamPSSnapin; Get-VBRJob | ?{$_.GetLastState() -eq 'Working'} | Stop-VBRJob"
4 - If the shell is running, terminate it.

Code: Select all

Taskkill /IM veeam.backup.shell.exe /F
5 - Stop all Veeam services

Code: Select all

powershell.exe -nologo -executionpolicy bypass -noprofile -command "Get-Service Veeam* | Stop-Service -Force"
6 - Uninstall all software beginning with "Veeam" as it has multiple components

Code: Select all

powershell -command "$product = \"Veeam*\";$UninstallKeys = @('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall');$uninstallKeys = foreach ($key in (Get-ChildItem $UninstallKeys) ) {if ($key.GetValue(\"DisplayName\") -like \"$product\") {[pscustomobject]@{UninstallString = $key.GetValue(\"UninstallString\");}}};foreach ($key in $uninstallkeys) {$uninstallString = $key.UninstallString;if ($uninstallString.StartsWith('MsiExec.exe')) {$uninstallString = $uninstallString.replace('/I','/X') + ' /qb- /quiet /passive /norestart'} else {$uninstallString = ' '}& cmd /c $uninstallString}"
7 - This one is an as of yet unsolved Anomaly. When installing via the GUI, it drops SQL2016 in place. However in my script testing, it behaved identically if I dropped it in place or not. For now, this line is unused, however providing install code for posterity

Code: Select all

start /wait C:\temp\veeam9.5u4\Redistr\x64\SqlExpress\2016SP1\SQLEXPR_x64_ENU.exe /Q /ACTION=Install /FEATURES=SQL /INSTANCENAME=VEEAMSQL2016 /SQLSVCACCOUNT="NT AUTHORITY\SYSTEM" /SQLSYSADMINACCOUNTS="Builtin\Administrators" /AGTSVCACCOUNT="NT AUTHORITY\SYSTEM" /IACCEPTSQLSERVERLICENSETERMS
8 - Install the backup catalog

Code: Select all

start /wait msiexec.exe /L*v "C:\temp\InstallLogs01Catalog.txt" /qn /i "C:\temp\veeam9.5u4\Catalog\VeeamBackupCatalog64.msi"  ACCEPT_THIRDPARTY_LICENSES="1"
9 - Install the Server

Code: Select all

start /wait msiexec.exe /L*v "C:\temp\InstallLogs02Server.txt" /qn /i "C:\temp\veeam9.5u4\Backup\Server.x64.msi" ACCEPTEULA="YES" ACCEPT_THIRDPARTY_LICENSES="1" VBR_LICENSE_FILE="C:\Temp\YOURLICENCEHERE.lic" VBR_AUTO_UPGRADE="YES"
10 - Install the Shell

Code: Select all

start /wait msiexec.exe /L*v "C:\temp\InstallLogs03Shell.txt" /qn /i "C:\temp\veeam9.5u4\Backup\Shell.x64.msi" ACCEPTEULA="YES" ACCEPT_THIRDPARTY_LICENSES="1"
11 - Install AD Explorer

Code: Select all

start /wait msiexec.exe /L*v "C:\temp\InstallLogs04AD.txt" /qn /i "C:\temp\veeam9.5u4\Explorers\VeeamExplorerForActiveDirectory.msi" ACCEPT_EULA="1" ACCEPT_THIRDPARTY_LICENSES="1"
12 - Install Exchange Explorer

Code: Select all

start /wait msiexec.exe /L*v "C:\temp\InstallLogs05Exchange.txt" /qn /i "C:\temp\veeam9.5u4\Explorers\VeeamExplorerForExchange.msi" ACCEPT_EULA="1" ACCEPT_THIRDPARTY_LICENSES="1"
13 - Install Oracle Explorer

Code: Select all

start /wait msiexec.exe /L*v "C:\temp\InstallLogs06Oracle.txt" /qn /i "C:\temp\veeam9.5u4\Explorers\VeeamExplorerForOracle.msi" ACCEPT_EULA="1" ACCEPT_THIRDPARTY_LICENSES="1"
14 - Install Sharepoint Explorer

Code: Select all

start /wait msiexec.exe /L*v "C:\temp\InstallLogs07Sharepoint.txt" /qn /i "C:\temp\veeam9.5u4\Explorers\VeeamExplorerForSharePoint.msi" ACCEPT_EULA="1" ACCEPT_THIRDPARTY_LICENSES="1"
15 - Install SQL Explorer

Code: Select all

start /wait msiexec.exe /L*v "C:\temp\InstallLogs08SQL.txt" /qn /i "C:\temp\veeam9.5u4\Explorers\VeeamExplorerForSQL.msi" ACCEPT_EULA="1" ACCEPT_THIRDPARTY_LICENSES="1"
16 - Install Linux Agent Redistributable

Code: Select all

start /wait msiexec.exe /L*v "C:\temp\InstallLogs09LinuxRedist.txt" /qn /i "C:\temp\veeam9.5u4\Packages\VALRedist.msi" ACCEPT_THIRDPARTY_LICENSES="1"
17 - Install Windows Agent Redistributable

Code: Select all

start /wait msiexec.exe /L*v "C:\temp\InstallLogs10WindowsRedist.txt" /qn /i "C:\temp\veeam9.5u4\Packages\VAWRedist.msi" ACCEPT_THIRDPARTY_LICENSES="1"
18 - Ensure all Veeam services are started

Code: Select all

powershell -command "get-service -displayname *veeam* | foreach-object { Start-Service -InputObj $_.Name }"
19 - Re-Scan all the things

Code: Select all

powershell.exe -nologo -executionpolicy bypass -noprofile -command "Add-PSSnapin VeeamPSSnapin; Rescan-VBREntity -AllHosts -AllCloudProviders -AllRepositories -AllReplicas -Wait"
20 - Reboot.

I will probably be tweaking this over the coming days, but the big takeaway is that this is possible. The documentation Veeam provides is inaccurate to the point of being misleading, and the lack of a single flag in place upgrade option is highly disappointing. For an enterprise product, seems like quite the oversight! Also, having both undocumented and non uniform MSI flags was quite the challenge.

Have fun!
nielsengelen
Product Manager
Posts: 5796
Liked: 1215 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Mass Upgrade to 9.5u4

Post by nielsengelen » 2 people like this post

Thanks a lot for sharing this! That is one amazing post! In regards to the documentation, I will pass the info along to have it modified/improved.
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
anthonyspiteri79
Veeam Software
Posts: 742
Liked: 209 times
Joined: Jan 14, 2016 6:48 am
Full Name: Anthony Spiteri
Location: Perth, Australia
Contact:

Re: Mass Upgrade to 9.5u4

Post by anthonyspiteri79 » 1 person likes this post

That is amazing actually. I've got some ideas on how to reuse this in some of the work we have done with Terraform. Great stuff!
Anthony Spiteri
Regional CTO APJ & Lead Cloud and Service Provider Technologist
Email: anthony.spiteri@veeam.com
Twitter: @anthonyspiteri
tdewin
Veeam Software
Posts: 1818
Liked: 655 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Mass Upgrade to 9.5u4

Post by tdewin » 2 people like this post

One thing that you might consider is disabling the jobs as well (but then you would have to enable them as well). I guess it is a corner case, but there could be a moment where a job (re)start between stopping the running jobs and the uninstall
quinnvanorder
Influencer
Posts: 15
Liked: 16 times
Joined: Jan 31, 2019 2:25 am
Full Name: Quinn Van Order
Location: Seattle WA
Contact:

Re: Mass Upgrade to 9.5u4

Post by quinnvanorder »

For the documentation, the main things I found were
1) References to onedrive explorer, I couldn't even find a package for that in the media for u4, possibly an old component?
2) Required flag on the backup catalog not documented, results in error 1603 "third party check" when digging into the logs.
3) Just a lot of required packages not mentioned to install at all.

Also, from what I can tell, running an install through the GUI doesn't upgrade several components automatically, prompting for them to be upgraded on both the hypervisor and the Veeam server. Those components are installed ahead of time with this approach, avoiding that point of potential disruption.

As for Disabling, I had considered that. My assumption, proven out in admittedly limited testing thus far, is that if I cleanly stop jobs, terminate the shell process, and then terminate all services is that Veeam is unable to restart itself to fire off more jobs. If that is incorrect let me know. The reason I took that approach is that we occasionally have jobs already disabled for various reasons. So if I did a global disable, and then global re-enable, I may end up turning back on jobs that were purposely disabled for whatever reason. I am sure with time I could whip something up that dumps the names of jobs that are enabled prior to disabling, back that up to a txt file, and then use that to re-enable them. That said, unless my assumption about killing the services is incorrect, I have found that to be a much simpler solution. I have seen the services come up as each component is installed, perhaps re-killing any running veeam services after each install line would achieve a more reliable stop on jobs?

I have been discussing this with support as well, and from what they have sent me, the SQL install is optional assuming this is an in place upgrade from 9.5. The requirements for u4 are as follows ( https://helpcenter.veeam.com/docs/backu ... l?ver=95u4 ), and they should already be in place assuming this is being run as a fresh upgrade.

While I have not tested it, I would assume that doing a fresh install would require the sql2016 line as well.

Also an as of yet tested eventuality is backing up anything that uses agents or vmware. I will be testing those out over the next few days / weeks. Its possible they will have other components that require additions to my script. Thus far, all of my testing is assuming HyperV hosts for the machines being backed up.

For anyone looking to break apart installers like this, I highly recommend SuperOrca, a free utility that can be used to read MSI's ( http://www.pantaray.com/msi_super_orca.html )

In general, flags that can be passed to MSI's are in the properties table, however I found several instances of that not being the case here. For those, I ran a global search for terms like "accept" and "eula" to find what I needed.
nielsengelen
Product Manager
Posts: 5796
Liked: 1215 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Mass Upgrade to 9.5u4

Post by nielsengelen » 1 person likes this post

For point 1, the onedrive explorer is part of the sharepoint explorer install so we should clarify it.
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
tsightler
VP, Product Management
Posts: 6035
Liked: 2860 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Mass Upgrade to 9.5u4

Post by tsightler »

quinnvanorder wrote: Jan 31, 2019 2:48 am But thats not all! If you just do this, the next time Veeam fires up, it will want you to upgrade components on your HyperV hosts as well. I have a script to deal with that as well.
Could you not just use the VBR_AUTO_UPGRADE option for the server install for this or is there some reason this did not work for you in your use case? That was exactly what it was intended to address, so if there are cases where it doesn't work that would be good information.
quinnvanorder
Influencer
Posts: 15
Liked: 16 times
Joined: Jan 31, 2019 2:25 am
Full Name: Quinn Van Order
Location: Seattle WA
Contact:

Re: Mass Upgrade to 9.5u4

Post by quinnvanorder »

According to the documentation, auto upgrade is not supported for V4

https://helpcenter.veeam.com/docs/backu ... l?ver=95u4

Check the bottom of the page. Admittedly I didn't test using this flag, I'll give it a shot now. If it works I will feel like a real goober, but I do try to read documentation and act accordingly prior to building stuff, so this may be a case of me being burned by documentation being incorrect :(

Testing now, will follow up shortly.
Automate all the things!
quinnvanorder
Influencer
Posts: 15
Liked: 16 times
Joined: Jan 31, 2019 2:25 am
Full Name: Quinn Van Order
Location: Seattle WA
Contact:

Re: Mass Upgrade to 9.5u4

Post by quinnvanorder »

Follow up - Yeah that doesn't work, it just opens the GUI and waits for user input.

Used the following string, which has worked on the past multiple versions:

C:\temp\Veeam9.5u4\setup.exe /silent /log C:\Logs\veeam.log VBR_AUTO_UPGRADE=1

It seems with major revisions, Veeam does not support a command line setup, I had to do similar reverse engineering for the jump from 9.0 to 9.5. Veeam hasn't managed to stop me yet! Clearly its possible, here is hoping future major version changes will support a command line upgrade feature to save us all this work :)
Automate all the things!
tsightler
VP, Product Management
Posts: 6035
Liked: 2860 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Mass Upgrade to 9.5u4

Post by tsightler » 1 person likes this post

Sorry for not being clear, I wasn't talking about running setup.exe, but when you install the server like above:

Code: Select all

start /wait msiexec.exe /L*v "C:\temp\InstallLogs02Server.txt" /qn /i "C:\temp\veeam9.5u4\Backup\Server.x64.msi" ACCEPTEULA="YES" ACCEPT_THIRDPARTY_LICENSES="1" VBR_LICENSE_FILE="C:\Temp\YOURLICENCEHERE.lic"
You should be able to add VBR_AUTO_UPGRADE="YES" to this and it will automatically upgrade all components once service starts. This should eliminate the need to manually run the scripts to deploy to Hyper-V/Proxies/Repos etc as this option is supposed to automatically push out the component upgrades so you don't get the popup to upgrade components the first time you start the GUI after upgrade. That's why this option exist and I've used it in the past with no issues.
quinnvanorder
Influencer
Posts: 15
Liked: 16 times
Joined: Jan 31, 2019 2:25 am
Full Name: Quinn Van Order
Location: Seattle WA
Contact:

Re: Mass Upgrade to 9.5u4

Post by quinnvanorder »

Woah, solid tip, I am implementing that now, thanks! I suspect that removes a few steps from the primary script as well, as it puts the installer and mount services in place. I will update my post to reflect this once I have it all tested out.
Automate all the things!
quinnvanorder
Influencer
Posts: 15
Liked: 16 times
Joined: Jan 31, 2019 2:25 am
Full Name: Quinn Van Order
Location: Seattle WA
Contact:

Re: Mass Upgrade to 9.5u4

Post by quinnvanorder »

Confirmed, so step 9 should be replaced with

Code: Select all

start /wait msiexec.exe /L*v "C:\temp\InstallLogs02Server.txt" /qn /i "C:\temp\veeam9.5u4\Backup\Server.x64.msi" ACCEPTEULA="YES" ACCEPT_THIRDPARTY_LICENSES="1" VBR_LICENSE_FILE="C:\Temp\YOURLICENCEHERE.lic" VBR_AUTO_UPGRADE="YES"
18 and 19 should be removed, and the entire second script becomes irrelevant.

Interestingly, I still get the false prompt to upgrade components that is cleared out by clicking refresh at first launch.

Thanks for the info tsightler
Automate all the things!
Gostev
Chief Product Officer
Posts: 31805
Liked: 7298 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Mass Upgrade to 9.5u4

Post by Gostev »

Hi, Quinn. I've used my mod superpowers to edit your original post accordingly, now that you can no longer modify it based on the age. Please check if everything is correct, and let me know if any further edits are required. Thanks for sharing this gem!
quinnvanorder
Influencer
Posts: 15
Liked: 16 times
Joined: Jan 31, 2019 2:25 am
Full Name: Quinn Van Order
Location: Seattle WA
Contact:

Re: Mass Upgrade to 9.5u4

Post by quinnvanorder »

Hey Gostev, it looks great, thanks for doing that!
Automate all the things!
quinnvanorder
Influencer
Posts: 15
Liked: 16 times
Joined: Jan 31, 2019 2:25 am
Full Name: Quinn Van Order
Location: Seattle WA
Contact:

Re: Mass Upgrade to 9.5u4

Post by quinnvanorder » 1 person likes this post

Update:

I have a few additions to this script now. I have found that each component, when installed, will turn on its corresponding services. As such, it can enable jobs to run midway through install which breaks all subsequent installs.

Previously, I had avoided disabling and enabling all jobs, as there may be cases where there is an old job in place which is disabled on purpose. Then doing a mass "enable all disabled jobs" could cause unexpected behavior. To address this, I took 2 paths simultaneously.

First, I use the code from Step 5 to stop all services between each install Steps 8 - 17

Second, I added code to export a csv with the names of all jobs that were enabled, read that csv into a variable and use it to first disable those jobs, and later to enable them. This ensures that any jobs that were disabled remain so, while making sure *all* jobs are disabled during install.

Third, I added "Veeam Distribution Service" to the list of installed components

Code below, assuming all needed component files are already downloaded and in the expected locations.

Code: Select all

#Backup Veeam Config
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Add-PSSnapin VeeamPSSnapin; Start-VBRConfigurationBackupJob"

#Stop all running Veeam Jobs
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Add-PSSnapin VeeamPSSnapin; Get-VBRJob | ?{$_.GetLastState() -eq 'Working'} | Stop-VBRJob"

#Disables all Veeam Jobs that were currently enabled. Writes target job list to CSV for resumption later. This avoids restarting jobs that were disabled prior to upgrade
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Add-PSSnapin VeeamPSSnapin; Get-VBRJob | where {$_.IsScheduleEnabled -eq $True} | select name | export-csv C:/temp/VeeamEnabledJobs.csv"
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Add-PSSnapin VeeamPSSnapin; Import-CSV C:/temp/VeeamEnabledJobs.csv | Disable-VBRJob -Job {$_.Name}"

#Terminate shell if running
Taskkill /IM veeam.backup.shell.exe /F

#Stop all Veeam services
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Get-Service Veeam* | Stop-Service -Force"

#Remove old Veeam instance
powershell -command "$product = \"Veeam*\";$UninstallKeys = @('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall');$uninstallKeys = foreach ($key in (Get-ChildItem $UninstallKeys) ) {if ($key.GetValue(\"DisplayName\") -like \"$product\") {[pscustomobject]@{UninstallString = $key.GetValue(\"UninstallString\");}}};foreach ($key in $uninstallkeys) {$uninstallString = $key.UninstallString;if ($uninstallString.StartsWith('MsiExec.exe')) {$uninstallString = $uninstallString.replace('/I','/X') + ' /qb- /quiet /passive /norestart'} else {$uninstallString = ' '}& cmd /c $uninstallString}"

#Begin u4 installers. Each install starts some services. They are then stopped for each component upgrade to avoid jobs starting unexpectedly
Install Backup Catalog
start /wait msiexec.exe /L*v "C:\temp\InstallLogs01Catalog.txt" /qn /i "C:\temp\veeam9.5u4\Catalog\VeeamBackupCatalog64.msi"  ACCEPT_THIRDPARTY_LICENSES="1"

#Stop all Veeam services
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Get-Service Veeam* | Stop-Service -Force"

#Install Server
start /wait msiexec.exe /L*v "C:\temp\InstallLogs02Server.txt" /qn /i "C:\temp\veeam9.5u4\Backup\Server.x64.msi" ACCEPTEULA="YES" ACCEPT_THIRDPARTY_LICENSES="1" VBR_LICENSE_FILE="C:\Temp\Veeam-200instances-entplus-monitoring.lic" VBR_AUTO_UPGRADE="YES"

#Stop all Veeam services
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Get-Service Veeam* | Stop-Service -Force"

#Install Shell
start /wait msiexec.exe /L*v "C:\temp\InstallLogs03Shell.txt" /qn /i "C:\temp\veeam9.5u4\Backup\Shell.x64.msi" ACCEPTEULA="YES" ACCEPT_THIRDPARTY_LICENSES="1"

#Stop all Veeam services
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Get-Service Veeam* | Stop-Service -Force"

#Install AD Explorer
start /wait msiexec.exe /L*v "C:\temp\InstallLogs04AD.txt" /qn /i "C:\temp\veeam9.5u4\Explorers\VeeamExplorerForActiveDirectory.msi" ACCEPT_EULA="1" ACCEPT_THIRDPARTY_LICENSES="1"

#Stop all Veeam services
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Get-Service Veeam* | Stop-Service -Force"

#Install Exchange Explorer
start /wait msiexec.exe /L*v "C:\temp\InstallLogs05Exchange.txt" /qn /i "C:\temp\veeam9.5u4\Explorers\VeeamExplorerForExchange.msi" ACCEPT_EULA="1" ACCEPT_THIRDPARTY_LICENSES="1"

#Stop all Veeam services
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Get-Service Veeam* | Stop-Service -Force"

#Install Oracle Explorer
start /wait msiexec.exe /L*v "C:\temp\InstallLogs06Oracle.txt" /qn /i "C:\temp\veeam9.5u4\Explorers\VeeamExplorerForOracle.msi" ACCEPT_EULA="1" ACCEPT_THIRDPARTY_LICENSES="1"

#Stop all Veeam services
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Get-Service Veeam* | Stop-Service -Force"

#Install Sharepoint Explorer
start /wait msiexec.exe /L*v "C:\temp\InstallLogs07Sharepoint.txt" /qn /i "C:\temp\veeam9.5u4\Explorers\VeeamExplorerForSharePoint.msi" ACCEPT_EULA="1" ACCEPT_THIRDPARTY_LICENSES="1"

#Stop all Veeam services
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Get-Service Veeam* | Stop-Service -Force"

#Install SQL Explorer
start /wait msiexec.exe /L*v "C:\temp\InstallLogs08SQL.txt" /qn /i "C:\temp\veeam9.5u4\Explorers\VeeamExplorerForSQL.msi" ACCEPT_EULA="1" ACCEPT_THIRDPARTY_LICENSES="1"

#Stop all Veeam services
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Get-Service Veeam* | Stop-Service -Force"

#Install Linux Agent Redistributable
start /wait msiexec.exe /L*v "C:\temp\InstallLogs09LinuxRedist.txt" /qn /i "C:\temp\veeam9.5u4\Packages\VALRedist.msi" ACCEPT_THIRDPARTY_LICENSES="1"

#Stop all Veeam services
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Get-Service Veeam* | Stop-Service -Force"

#Install Windows Agent Redistributable
start /wait msiexec.exe /L*v "C:\temp\InstallLogs10WindowsRedist.txt" /qn /i "C:\temp\veeam9.5u4\Packages\VAWRedist.msi" ACCEPT_THIRDPARTY_LICENSES="1"

#Stop all Veeam services
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Get-Service Veeam* | Stop-Service -Force"

#Install Veeam Distribution Service
start /wait msiexec.exe /L*v "C:\temp\InstallLogs11VeeamDistributionSvc.txt" /qn /i "C:\temp\veeam9.5u4\Packages\VeeamDistributionSvc.msi" ACCEPT_THIRDPARTY_LICENSES="1"

#Ensure Veeam services are started
powershell -command "get-service -displayname *veeam* | foreach-object { Start-Service -InputObj $_.Name }"

#Restart all jobs that were previously enabled
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Add-PSSnapin VeeamPSSnapin; Import-CSV C:/temp/VeeamEnabledJobs.csv | Enable-VBRJob -Job {$_.Name}"

#Post Install Cleanup
powershell.exe -nologo -executionpolicy bypass -noprofile -command " If(test-path 'C:\temp\veeam9.5u4'){Remove-Item 'C:\temp\veeam9.5u4' -Recurse -Force}" 
powershell.exe -nologo -executionpolicy bypass -noprofile -command " If(test-path 'C:\temp\VeeamEnabledJobs.csv'){Remove-Item 'C:\temp\VeeamEnabledJobs.csv' -Force}" 

#Re-Scan all repos
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Add-PSSnapin VeeamPSSnapin; Rescan-VBREntity -AllHosts -AllCloudProviders -AllRepositories -AllReplicas -Wait"

#Clean stop and Reboot
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Add-PSSnapin VeeamPSSnapin; Get-VBRJob | ?{$_.GetLastState() -eq 'Working'} | Stop-VBRJob"
powershell.exe -nologo -executionpolicy bypass -noprofile -command "Get-Service Veeam* | Stop-Service -Force"
shutdown -r -f -t 0
Automate all the things!
chris.arceneaux
VeeaMVP
Posts: 695
Liked: 374 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Georgia, USA
Contact:

Re: Mass Upgrade to 9.5u4

Post by chris.arceneaux » 2 people like this post

I recently added a script to VeeamHub to automate the upgrade from 9.5 Update 4b to v10.

https://github.com/VeeamHub/powershell/ ... UpgradeV10
Elemer.gazda
Influencer
Posts: 17
Liked: 4 times
Joined: Feb 14, 2018 12:01 pm
Full Name: Elemer Gazda
Contact:

Re: Mass Upgrade to 9.5u4

Post by Elemer.gazda »

@Chris.arceneaux

FYI:
in your script you are using an inaccurate way of determining the Veeam BR version.
If Veeam has been installed and later updated with the EXEs the version number you are using won't update.
I would use the following to determine Veeam BR version:

Code: Select all

    $CorePath = Get-ItemProperty -Path "HKLM:\Software\Veeam\Veeam Backup and Replication\" -Name "CorePath"
    $DepDLLPath = Join-Path -Path $CorePath.CorePath -ChildPath "Packages\VeeamDeploymentDll.dll" -Resolve
    $File = Get-Item -Path $DepDLLPath
    [Version]$VeeamVersion = $file.VersionInfo.ProductVersion
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Mass Upgrade to 9.5u4

Post by oleg.feoktistov »

Haven't tested these cases yet, but maybe @chris.arceneaux have and could help us out here.
chris.arceneaux
VeeaMVP
Posts: 695
Liked: 374 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Georgia, USA
Contact:

Re: Mass Upgrade to 9.5u4

Post by chris.arceneaux » 1 person likes this post

Hi Elemer,

Thanks for the heads up. I use that method as well.

You are correct that my method of pulling the version number will not update when patches are applied to VBR. For the use case in the script I posted above, it works as needed to make sure someone doesn't accidentally run the upgrade script against a server that's already been upgraded.

Thanks for supporting Veeam forums!
ryan1cf
Service Provider
Posts: 26
Liked: 3 times
Joined: Apr 19, 2017 3:47 pm
Full Name: Ryan Faulkner
Contact:

Re: Mass Upgrade to 9.5u4

Post by ryan1cf » 2 people like this post

chris.arceneaux wrote: Mar 03, 2020 3:34 pm I recently added a script to VeeamHub to automate the upgrade from 9.5 Update 4b to v10.

https://github.com/VeeamHub/powershell/ ... UpgradeV10
Thanks for this, I've modified your script to upgrade 10.0.0.4461 to 10.0.1.4854
Changes I made:

Line 304 changed to
if (($vem.Version -eq "10.0.1.4854") -or ($vbr.Version -eq "10.0.1.4854")) {


Line 318 changed to
Start-BitsTransfer -Source "https://download2.veeam.com/VeeamBackup ... 1.4854.iso" -Destination $iso


Under Beginning VBR upgrade, the if line 492 for VeeamBackupCatalog64.msi install, to this:
if ($result -eq 0 -or $result -eq 3010) { Write-Log "SUCCESS: ${result}" }

The 3010 code is still a successfully installed code but package requires a restart.

I also changed the if ISO wasn't specified but not really needed since I was inputting where the ISO and license file was.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 14 guests