Advertisement
Guest User

Untitled

a guest
Feb 16th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.35 KB | None | 0 0
  1. [CmdletBinding()]
  2. $NSXUsername = "admin"
  3. $NSXPassword = "VMware1!"
  4. $uriP = "https://HQ-NSX-01a.nsx.gss"
  5.  
  6.  
  7. # Start time.
  8. $startclock = (Get-Date)
  9. Write-Host -BackgroundColor:Black -ForegroundColor:Green "Hello"
  10. Write-Host -BackgroundColor:Black -ForegroundColor:Green "This script will help you to automate a full NSX environment UPgrade"
  11. 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
  12. ========================================================================================
  13. "
  14.  
  15.  
  16.  
  17.  
  18. # Create NSX authorization string and store in $head and used in API Calls
  19. # $nsxcreds = New-Object System.Management.Automation.PSCredential $NSXUsername,$NSXPassword
  20. $auth = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($NSXUsername + ":" + $NSXPassword))
  21. $head = @{"Authorization"="Basic $auth"}
  22.  
  23. # Allow untrusted SSL certs else will error out
  24. add-type @"
  25. using System.Net;
  26. using System.Security.Cryptography.X509Certificates;
  27. public class TrustAllCertsPolicy : ICertificatePolicy {
  28. public bool CheckValidationResult(
  29. ServicePoint srvPoint, X509Certificate certificate,
  30. WebRequest request, int certificateProblem) {
  31. return true;
  32. }
  33. }
  34. "@
  35. [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
  36.  
  37. ##################################################
  38. # Choosing the required NSX Version to be deployed
  39. ##################################################
  40.  
  41. [int]$menuoptions = 0
  42. while ( $menuoptions -lt 1 -or $menuoptions -gt 12 ) {
  43. 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) "
  44. Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 1.NSX-6.2.0 "
  45. Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 2.NSX-6.2.1 "
  46. Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 3.NSX-6.2.1a "
  47. Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 4.NSX-6.2.2 "
  48. Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 5.NSX-6.2.2a "
  49. Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 6.NSX-6.2.2b "
  50. Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 7.NSX-6.2.3 "
  51. Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 8.NSX-6.2.3a "
  52. Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 9.NSX-6.2.3b "
  53. Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 10.NSX-6.2.4 "
  54. Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 11.NSX-6.2.5 "
  55. Write-host -BackgroundColor:Black -ForegroundColor:Yellow " 12.NSX-6.3.6 "
  56. [int]$menuoptions = read-host
  57. if ($menuoptions -lt 1 -or $menuoptions -gt 12) {Write-host -BackgroundColor:Black -ForegroundColor:Red " Invalid Input Detected, Please choose a valid input"}
  58. }
  59. Switch( $menuoptions ) {
  60. 1{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.0-2986609.tar.gz"}
  61. 2{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.1-3300239.tar.gz"}
  62. 3{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.1a-3496286.tar.gz"}
  63. 4{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.2-3604087.tar.gz"}
  64. 5{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.2a-3638734.tar.gz"}
  65. 6{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.2b-3755950.tar.gz"}
  66. 7{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.3-3979471.tar.gz"}
  67. 8{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.3a-4167369.tar.gz"}
  68. 9{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.3b-4287432.tar.gz"}
  69. 10{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.4-4292526.tar.gz"}
  70. 11{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.5-4818372.tar.gz"}
  71. 12{$nsxpath = "D:NSX-6.2.x-UPGrade-BundlesVMware-NSX-Manager-upgrade-bundle-6.2.6-4977495.tar.gz"}
  72. }
  73.  
  74. Switch( $menuoptions ) {
  75. 1{$nsxversion = "NSX-6.2.0"}
  76. 2{$nsxversion = "NSX-6.2.1"}
  77. 3{$nsxversion = "NSX-6.2.1a"}
  78. 4{$nsxversion = "NSX-6.2.2"}
  79. 5{$nsxversion = "NSX-6.2.2a"}
  80. 6{$nsxversion = "NSX-6.2.2b"}
  81. 7{$nsxversion = "NSX-6.2.3"}
  82. 8{$nsxversion = "NSX-6.2.3a"}
  83. 9{$nsxversion = "NSX-6.2.3b"}
  84. 10{$nsxversion = "NSX-6.2.4"}
  85. 11{$nsxversion = "NSX-6.2.5"}
  86. 12{$nsxversion = "NSX-6.3.6"}
  87. }
  88.  
  89.  
  90. #===========================================================================================================================================
  91. #===========================================================================================================================================
  92.  
  93.  
  94. #########################
  95. # Upgrading NSX Manager
  96. #########################
  97.  
  98. Write-Host -BackgroundColor:Black -ForegroundColor:Green "1. Deploying NSX Manager with version $nsxversion"
  99.  
  100. Write-Host -BackgroundColor:Black -ForegroundColor:Yellow " UPloading the required upgrade bundel to NSX Manager"
  101.  
  102.  
  103. $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