How to move an SRW machine from one server to another.

How to move a SRW machine from one server to another. #SRW-KB18

Written by Giuseppe

Last published at: April 22nd, 2021

If you want to migrate a client from one server to another, (I.E. from a Cloud PoC to an OnPrem server)  follow these simple steps:



  • To move an existing device you can use the Migration Helper functionality inside the console to generate scripts or registry keys.


That information can be subsequently used in a software package or simply inside the profile editor.


Generate script :

where the MgmtUri is your Server URI

MgmtUsername is the site username  

MgmtPassword is the site password


Option Explicit

Dim objWSHShell

Set objWSHShell = WScript.CreateObject("WScript.Shell")

Dim brokerPath

brokerPath = "HKLM\SOFTWARE\ThinKiosk\ConnectionInfo\"

If Is32BitOS() = False Then

    brokerPath = "HKLM\SOFTWARE\WOW6432Node\ThinKiosk\ConnectionInfo\"

End If

objWSHShell.RegWrite brokerPath & "MgmtUri", "https://YOURSERVER/tstmgmt", "REG_SZ"

objWSHShell.RegWrite brokerPath & "MgmtUsername", "QZ9n36G907WCmP", "REG_SZ"

objWSHShell.RegWrite brokerPath & "MgmtPassword", "2TiRRmHbGSON4obWe8RzpdCGS9c", "REG_SZ"

Function Is32BitOS()

    If GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth = 32 Then

        Is32BitOS = True

    Else

        Is32BitOS = False

    End If

End Function


32-Bit Registry


64-Bit Registry


Profile Editor


Sofware Package

VBS


Option Explicit
Dim objWSHShell
Set objWSHShell = WScript.CreateObject("WScript.Shell")
Dim objWMIService, objItem, objService
Dim colListOfServices, strComputer, strService, intSleep
strComputer = "."
intSleep = 1000

If regValueExists("HKLM\SOFTWARE\WOW6432Node\ThinKiosk\ConnectionInfo\Moved") Then
Wscript.Echo "The registry does exists"
WScript.Quit
Else
Wscript.Echo "The registry key does not exists."

objWSHShell.RegWrite "HKLM\SOFTWARE\WOW6432Node\ThinKiosk\ConnectionInfo\MgmtUri", "yourserver", "REG_SZ"
objWSHShell.RegWrite "HKLM\SOFTWARE\WOW6432Node\ThinKiosk\ConnectionInfo\MgmtUsername", "yourusername", "REG_SZ"
objWSHShell.RegWrite "HKLM\SOFTWARE\WOW6432Node\ThinKiosk\ConnectionInfo\MgmtPassword", "yourpassword", "REG_SZ"
objWSHShell.RegWrite "HKLM\SOFTWARE\WOW6432Node\ThinKiosk\ConnectionInfo\Moved", "Yes", "REG_SZ"

strService = " 'SecureRemoteWorkerMachineService' "
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name ="_
& strService & " ")
For Each objService in colListOfServices
objService.StopService()
WScript.Echo "The " & strService & " service has been stopped"
WScript.Sleep intSleep
objService.StartService()
Next
WScript.Echo "The " & strService & " service has Started"
WScript.Quit
End If


Function regValueExists (key)
'This function checks if a registry value exists and returns True of False
On Error Resume Next
Dim oShell
Set oShell = CreateObject ("WScript.Shell")
regValueExists = True
Err.Clear
oShell.RegRead(key)
If Err <> 0 Then regValueExists = False
Err.Clear
Set oShell = Nothing
End Function