Upgrading many CloudMigrator servers can be a time-consuming process. This can be streamlined by making using of PowerShell and WinRM whereby multiple servers can be upgraded remotely without even needing to log onto the server.
The following PowerShell script can be used to perform a remote upgrade of a server. How to call the script is detailed in the comments at the top of the script.
Remote CloudMigrator Upgrade
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#------------------------------------------------------------------------------ # CloudMigrator Remote Update Script # Usage: WinRMUpgrade.ps1 -installerUrl url -ipAddresses addresses -admin admin -password password # # -installerUrl must be the URL that the version of CloudMigrator to install can be downloaded from # -ipAddresses should be an address, or comma separated list of addresses to install to # -admin should be the admin username of the Windows Server specified in ipAddresses # -password should be the password of the admin user # # Note: This must be run from an elevated powershell prompt (run as administrator) # Note: To upgrade multiple servers, specify a comma separated list of addresses #------------------------------------------------------------------------------ param([string[]] $ipAddresses ,[string] $installerUrl ,[string] $admin ,[string] $password ) $ErrorActionPreference = 'Stop' # The script that will be passed to the remote server $remoteScript = { param([string] $installerUrl ) $ErrorActionPreference = 'Stop' # Download the installer and save it to temp Write -Output ( "Downloading installer from " + $installerUrl ) Invoke -WebRequest $installerUrl -outfile C:\Windows\Temp\CloudMigrator -Upgrade .exe $arguments = "-q" ; # Run the installer quietly from the downloaded location Write -Output ( "Running installer..." ) [diagnostics.process]::Start( "C:\Windows\Temp\CloudMigrator-Upgrade.exe" , $arguments ).WaitForExit(); Write -Output ( "Upgrade completed" ) } # Ignore the CA and CN for SSL as we probably have self-signed certs $options =New -PSSessionOption -SkipCNCheck -SkipCACheck # Build the credential object $cred = New-object -TypeName System.Management.Automation.PSCredential -argumentlist $admin ,( ConvertTo-SecureString $password -AsPlainText -Force ) $connectionUris = @() foreach ( $ipAddress in $ipAddresses -split ',' ) { } Write -Output ( "**************************************************************" ) Write -Output ( "* CloudMigrator remote server update - " + $( Get-Date -Format G)); Write -Output ( "* Updating addresses: " + $ipAddresses ) Write -Output ( "* Build: " + $installerUrl ) Write -Output ( "**************************************************************" ) # Call the remote server passing the argument list for the script Invoke -Command -Credential $cred -ScriptBlock $remoteScript -ArgumentList $installerUrl -ConnectionUri $connectionUris -SessionOption $options |
Comments
0 comments
Please sign in to leave a comment.