Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [CmdletBinding()]
- $NSXUsername = "admin"
- $NSXPassword = "VMware1!"
- $uriP = "https://HQ-NSX-01a.nsx.gss"
- # Start time.
- $startclock = (Get-Date)
- Write-Host -BackgroundColor:Black -ForegroundColor:Green "Hello"
- Write-Host -BackgroundColor:Black -ForegroundColor:Green "This script will help you to automate a full NSX environment UPgrade"
- Write-Host -BackgroundColor:Black -ForegroundColor:Green "FULL NSX Tier UPgrade for Single-VC is starting, This UPgrade proccess will take an average of 40 min
- ========================================================================================
- "
- # Create NSX authorization string and store in $head and used in API Calls
- # $nsxcreds = New-Object System.Management.Automation.PSCredential $NSXUsername,$NSXPassword
- $auth = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($NSXUsername + ":" + $NSXPassword))
- $head = @{"Authorization"="Basic $auth"}
- # Allow untrusted SSL certs else will error out
- add-type @"
- using System.Net;
- using System.Security.Cryptography.X509Certificates;
- public class TrustAllCertsPolicy : ICertificatePolicy {
- public bool CheckValidationResult(
- ServicePoint srvPoint, X509Certificate certificate,
- WebRequest request, int certificateProblem) {
- return true;
- }
- }
- "@
- [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
- ##################################################
- # Choosing the required NSX Version to be deployed
- ##################################################
- [int]$menuoptions = 0
- while ( $menuoptions -lt 1 -or $menuoptions -gt 12 ) {
- Write-host -BackgroundColor:Black -ForegroundColor:Red " Please choose the required version of NSX to be deployed (Accepted inputs are a number from 1 to 12) "
- Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 1.NSX-6.2.0 "
- Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 2.NSX-6.2.1 "
- Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 3.NSX-6.2.1a "
- Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 4.NSX-6.2.2 "
- Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 5.NSX-6.2.2a "
- Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 6.NSX-6.2.2b "
- Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 7.NSX-6.2.3 "
- Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 8.NSX-6.2.3a "
- Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 9.NSX-6.2.3b "
- Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 10.NSX-6.2.4 "
- Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 11.NSX-6.2.5 "
- Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 12.NSX-6.3.6 "
- [int]$menuoptions = read-host
- if ($menuoptions -lt 1 -or $menuoptions -gt 12) {Write-host -BackgroundColor:Black -ForegroundColor:Red " Invalid Input Detected, Please choose a valid input"}
- }
- Switch( $menuoptions ) {
- 1{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.0-2986609.tar.gz"}
- 2{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.1-3300239.tar.gz"}
- 3{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.1a-3496286.tar.gz"}
- 4{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.2-3604087.tar.gz"}
- 5{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.2a-3638734.tar.gz"}
- 6{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.2b-3755950.tar.gz"}
- 7{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.3-3979471.tar.gz"}
- 8{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.3a-4167369.tar.gz"}
- 9{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.3b-4287432.tar.gz"}
- 10{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.4-4292526.tar.gz"}
- 11{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.5-4818372.tar.gz"}
- 12{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.6-4977495.tar.gz"}
- }
- Switch( $menuoptions ) {
- 1{$nsxversion = "NSX-6.2.0"}
- 2{$nsxversion = "NSX-6.2.1"}
- 3{$nsxversion = "NSX-6.2.1a"}
- 4{$nsxversion = "NSX-6.2.2"}
- 5{$nsxversion = "NSX-6.2.2a"}
- 6{$nsxversion = "NSX-6.2.2b"}
- 7{$nsxversion = "NSX-6.2.3"}
- 8{$nsxversion = "NSX-6.2.3a"}
- 9{$nsxversion = "NSX-6.2.3b"}
- 10{$nsxversion = "NSX-6.2.4"}
- 11{$nsxversion = "NSX-6.2.5"}
- 12{$nsxversion = "NSX-6.3.6"}
- }
- #===========================================================================================================================================
- #===========================================================================================================================================
- #########################
- # Upgrading NSX Manager
- #########################
- Write-Host -BackgroundColor:Black -ForegroundColor:Green "1. Deploying NSX Manager with version $nsxversion"
- Write-Host -BackgroundColor:Black -ForegroundColor:Yellow " UPloading the required upgrade bundel to NSX Manager"
- $r = Invoke-WebRequest -Uri "$uriP/api/1.0/appliance-management/upgrade/uploadbundle/NSX" -Method:Post -Headers $head -ContentType "application/xml" -InFile $nsxpath -TimeoutSec 66000 -DisableKeepAlive
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement