locked
USMT with SMP in SCCM OSD: Side-by-side Migration RRS feed

  • Question

  • Hi,

    I have been trying to carry out a completely automated side-by-side Bare Metal hardware replace using SMP. However for unknown computers it seems that this is not possible as the Computer Association becomes invalid once the new machine is imaged and has  SCCM client configured as a part of the OSD TS. (even if I have imported the new computer object in manually). 

    Is a side-by-side migration with USMT+SMP on a baremetal possible? I know I can run the USMT capture and restore once the machine is built.

     


    Hulikal
    Monday, June 13, 2011 1:01 PM

Answers

  • I've cobbled together a couple of scripts to aid in migrations to bare metal.

    This script detects the model of the target PC in the ConfigMgr database and sets a task sequence variable so that it uses USMT v3.01 if the target machine will be running XP, otherwise it uses USMT4:

     

    Server = "Server.domain.local"
    userName = "SMSAccess@domain"
    userPassword = "password"
    
    Set oADSysInfo = CreateObject("ADSystemInfo")
    Set oComputer = GetObject("LDAP://" & oADSysInfo.ComputerName)
    strcomputera = oComputer.CN
    
    Dim computera, ResID, Status, Env
    Set connection = Connect(Server, userName, userPassword)
    Set Env = CreateObject("Microsoft.SMS.TSEnvironment")
    ResID = GetResourceIDFromName (connection, strcomputera)
    Status = MigrationState (connection, ResID)
    
    Function Connect(server, userName, userPassword)
    
       Dim net
       Dim localConnection
       Dim swbemLocator
       Dim swbemServices
       Dim providerLoc
       Dim location
       
       Set swbemLocator = CreateObject("WbemScripting.SWbemLocator")'
       swbemLocator.Security_.AuthenticationLevel = 6
       Set swbemServices= swbemLocator.ConnectServer (server, "root\sms",userName,userPassword)
       
       If Err.Number<>0 Then
          Connect = Null
          Exit Function
       End If
    
       Set providerLoc = swbemServices.InstancesOf("SMS_ProviderLocation")
       
       For Each location In providerLoc
          If location.ProviderForLocalSite = True Then
             Set swbemServices = swbemLocator.ConnectServer(location.Machine, "root\sms\site_" + location.SiteCode,userName,userPassword)
             If Err.Number<>0 Then
                Connect = Null
                Exit Function
             End If
             Set Connect = swbemServices
             Exit Function
          End If
       Next
       
       Set Connect = Null
       
    End Function
    
    Function GetResourceIDFromName(connection, strcomputera)
    
       query = "SELECT * FROM SMS_R_System WHERE NetbiosName = """ & strcomputera & """"
       
       Set result = connection.ExecQuery(query)
       
       If Err then
          Exit Function
       End If
       
       resourceID = 0
       
       For each r in result
          GetResourceIDFromName = r.ResourceID
       Next
       
    End Function
    
    Function MigrationState(connection, ResID)
    
       Dim migrations
       Dim migration
       
       Set migrations = connection.ExecQuery("SELECT * FROM SMS_StateMigration WHERE SMS_StateMigration.SourceClientResourceID = " & ResID)
    
       For Each migration in Migrations
          If migration.SourceClientResourceID = ResID Then
             TargetResID = migration.RestoreClientResourceID
             Env("Migration") = "Side-By-Side"
             Exit For
          End If
       Next
    
       Set Targets = connection.ExecQuery("SELECT * FROM SMS_G_System_COMPUTER_SYSTEM WHERE ResourceID = """ & TargetResID & """")
       
       For Each Target in Targets
          If Target.ResourceID = TargetResID Then
             Model = Target.Model
             Model = Trim(Model)
             Select Case Model
                    Case "Latitude 110L" : Env("USMTVersion") = "Legacy"
                    Case "Latitude 120L" : Env("USMTVersion") = "Legacy"
                    Case "OptiPlex 170L" : Env("USMTVersion") = "Legacy"
                    Case "OptiPlex 210L" : Env("USMTVersion") = "Legacy"
                    Case "OptiPlex GX270" : Env("USMTVersion") = "Legacy"
                    Case "OptiPlex GX280" : Env("USMTVersion") = "Legacy"
                    Case "OptiPlex GX520" : Env("USMTVersion") = "Legacy"
                    Case "OptiPlex GX620" : Env("USMTVersion") = "Legacy"
                                                    Case Else  : Env("USMTVersion") = "Current"
                                    End Select
             Exit For
          End If
       Next
    
    End Function  

    Then I run this script in my task sequence to check if a MigrationStore has a UserState to deploy to the bare metal PC:

     

     

    Server = "Server.domain.local"
    userName = "SMSAccess@domain"
    userPassword = "password"
    
    Dim ResID, Status, SMBIOSGUID, Env
    
    Set connection = Connect(Server, userName, userPassword)
    Set Env = CreateObject("Microsoft.SMS.TSEnvironment")
    
    SMBIOSGUID = GetSMBIOSGUID()
    ResID = GetResourceIDFromSMBIOSGUID (connection, SMBIOSGUID)
    Status = MigrationState (connection, ResID)
    
    Function Connect(server, userName, userPassword)
       Dim net
       Dim localConnection
       Dim swbemLocator
       Dim swbemServices
       Dim providerLoc
       Dim location
       Set swbemLocator = CreateObject("WbemScripting.SWbemLocator")'
       swbemLocator.Security_.AuthenticationLevel = 6
       Set swbemServices= swbemLocator.ConnectServer (server, "root\sms",userName,userPassword)
       If Err.Number<>0 Then
          Connect = Null
          Exit Function
       End If
    
       Set providerLoc = swbemServices.InstancesOf("SMS_ProviderLocation")
       For Each location In providerLoc
          If location.ProviderForLocalSite = True Then
             Set swbemServices = swbemLocator.ConnectServer(location.Machine, "root\sms\site_" + location.SiteCode,userName,userPassword)
            If Err.Number<>0 Then
                Connect = Null
                Exit Function
             Set Connect = swbemServices
             Exit Function
          End If
       Next
       Set Connect = Null
    End Function
    
    Function GetSMBIOSGUID
       Dim cimv2Namespace, results, record, SMBIOSGUID
    
       Set cimv2Namespace = GetObject ("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\.\root\cimv2") 
       Set results = cimv2Namespace.ExecQuery ("SELECT UUID FROM Win32_ComputerSystemProduct")
       
       For Each record in results 
          SMBIOSGUID = record.UUID
          If SMBIOSGUID = "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF" Or SMBIOSGUID = "00000000-0000-0000-0000-000000000000" Then
             SMBIOSGUID = ""
          End If
       Next
    
       GetSMBIOSGUID = SMBIOSGUID
    End Function
    
    Function GetResourceIDFromSMBIOSGUID(connection, SMBIOSGUID)
    
       query = "SELECT * FROM SMS_R_System WHERE SMS_R_System.SMBIOSGUID = """ & SMBIOSGUID & """"
    
       Set result = connection.ExecQuery(query)
       resourceID = 0
       
       For each r in result
          GetResourceIDFromSMBIOSGUID = r.ResourceID
       Next
    End Function
    
    Function MigrationState(connection, ResID)
    
       Dim migrations
       Dim migration
       
       Set migrations = connection.ExecQuery("SELECT SMS_StateMigration.RestoreClientResourceID FROM SMS_StateMigration WHERE SMS_StateMigration.RestoreClientResourceID = " & ResID)
    
       For Each migration in Migrations
          If migration.RestoreClientResourceID = ResID Then
             Env("Migration") = "Side-By-Side"
             Exit For
          End If
       Next
    
    End Function 
     
    

    If it does find something to restore then it sets a Task Sequence Variable called 'Migration' to 'Side-By-Side'. I then set a condition on the 'Restore user files and settings' task sequence so that it restores from the StateMigration point if Migration=Side-By-Side

     


    • Proposed as answer by WorkProfile Tuesday, October 11, 2011 1:41 PM
    • Edited by WorkProfile Tuesday, October 11, 2011 1:42 PM
    • Marked as answer by Garth JonesMVP Thursday, December 31, 2015 5:40 PM
    Tuesday, October 11, 2011 1:40 PM

All replies

  • Hi Hulikal,

     

    Did you try to add a computer association with SCCM after the user state has already been captured from the old computer? If so, this is impossible.

     

    Please refer to the following links:

     

    Administrator Workflow: Capture User State

     

    Use the Import Microsoft Deployment Task Sequence Wizard and the Client Replace Task Sequence

     

    Regards,

     

    Sabrina


    This posting is provided "AS IS" with no warranties or guarantees, and confers no rights. |Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Wednesday, June 15, 2011 6:57 AM
  • Hi Sabrina,

     

    Computer Association was added before I USMT the machine. I had gone through the above mentioned documentation and I'm quiet clear on that part of USMT with OSD though..

    My only concern is the target machine being a Bare-Metal installation.

     


    Hulikal
    Wednesday, June 15, 2011 9:52 AM
  • I've cobbled together a couple of scripts to aid in migrations to bare metal.

    This script detects the model of the target PC in the ConfigMgr database and sets a task sequence variable so that it uses USMT v3.01 if the target machine will be running XP, otherwise it uses USMT4:

     

    Server = "Server.domain.local"
    userName = "SMSAccess@domain"
    userPassword = "password"
    
    Set oADSysInfo = CreateObject("ADSystemInfo")
    Set oComputer = GetObject("LDAP://" & oADSysInfo.ComputerName)
    strcomputera = oComputer.CN
    
    Dim computera, ResID, Status, Env
    Set connection = Connect(Server, userName, userPassword)
    Set Env = CreateObject("Microsoft.SMS.TSEnvironment")
    ResID = GetResourceIDFromName (connection, strcomputera)
    Status = MigrationState (connection, ResID)
    
    Function Connect(server, userName, userPassword)
    
       Dim net
       Dim localConnection
       Dim swbemLocator
       Dim swbemServices
       Dim providerLoc
       Dim location
       
       Set swbemLocator = CreateObject("WbemScripting.SWbemLocator")'
       swbemLocator.Security_.AuthenticationLevel = 6
       Set swbemServices= swbemLocator.ConnectServer (server, "root\sms",userName,userPassword)
       
       If Err.Number<>0 Then
          Connect = Null
          Exit Function
       End If
    
       Set providerLoc = swbemServices.InstancesOf("SMS_ProviderLocation")
       
       For Each location In providerLoc
          If location.ProviderForLocalSite = True Then
             Set swbemServices = swbemLocator.ConnectServer(location.Machine, "root\sms\site_" + location.SiteCode,userName,userPassword)
             If Err.Number<>0 Then
                Connect = Null
                Exit Function
             End If
             Set Connect = swbemServices
             Exit Function
          End If
       Next
       
       Set Connect = Null
       
    End Function
    
    Function GetResourceIDFromName(connection, strcomputera)
    
       query = "SELECT * FROM SMS_R_System WHERE NetbiosName = """ & strcomputera & """"
       
       Set result = connection.ExecQuery(query)
       
       If Err then
          Exit Function
       End If
       
       resourceID = 0
       
       For each r in result
          GetResourceIDFromName = r.ResourceID
       Next
       
    End Function
    
    Function MigrationState(connection, ResID)
    
       Dim migrations
       Dim migration
       
       Set migrations = connection.ExecQuery("SELECT * FROM SMS_StateMigration WHERE SMS_StateMigration.SourceClientResourceID = " & ResID)
    
       For Each migration in Migrations
          If migration.SourceClientResourceID = ResID Then
             TargetResID = migration.RestoreClientResourceID
             Env("Migration") = "Side-By-Side"
             Exit For
          End If
       Next
    
       Set Targets = connection.ExecQuery("SELECT * FROM SMS_G_System_COMPUTER_SYSTEM WHERE ResourceID = """ & TargetResID & """")
       
       For Each Target in Targets
          If Target.ResourceID = TargetResID Then
             Model = Target.Model
             Model = Trim(Model)
             Select Case Model
                    Case "Latitude 110L" : Env("USMTVersion") = "Legacy"
                    Case "Latitude 120L" : Env("USMTVersion") = "Legacy"
                    Case "OptiPlex 170L" : Env("USMTVersion") = "Legacy"
                    Case "OptiPlex 210L" : Env("USMTVersion") = "Legacy"
                    Case "OptiPlex GX270" : Env("USMTVersion") = "Legacy"
                    Case "OptiPlex GX280" : Env("USMTVersion") = "Legacy"
                    Case "OptiPlex GX520" : Env("USMTVersion") = "Legacy"
                    Case "OptiPlex GX620" : Env("USMTVersion") = "Legacy"
                                                    Case Else  : Env("USMTVersion") = "Current"
                                    End Select
             Exit For
          End If
       Next
    
    End Function  

    Then I run this script in my task sequence to check if a MigrationStore has a UserState to deploy to the bare metal PC:

     

     

    Server = "Server.domain.local"
    userName = "SMSAccess@domain"
    userPassword = "password"
    
    Dim ResID, Status, SMBIOSGUID, Env
    
    Set connection = Connect(Server, userName, userPassword)
    Set Env = CreateObject("Microsoft.SMS.TSEnvironment")
    
    SMBIOSGUID = GetSMBIOSGUID()
    ResID = GetResourceIDFromSMBIOSGUID (connection, SMBIOSGUID)
    Status = MigrationState (connection, ResID)
    
    Function Connect(server, userName, userPassword)
       Dim net
       Dim localConnection
       Dim swbemLocator
       Dim swbemServices
       Dim providerLoc
       Dim location
       Set swbemLocator = CreateObject("WbemScripting.SWbemLocator")'
       swbemLocator.Security_.AuthenticationLevel = 6
       Set swbemServices= swbemLocator.ConnectServer (server, "root\sms",userName,userPassword)
       If Err.Number<>0 Then
          Connect = Null
          Exit Function
       End If
    
       Set providerLoc = swbemServices.InstancesOf("SMS_ProviderLocation")
       For Each location In providerLoc
          If location.ProviderForLocalSite = True Then
             Set swbemServices = swbemLocator.ConnectServer(location.Machine, "root\sms\site_" + location.SiteCode,userName,userPassword)
            If Err.Number<>0 Then
                Connect = Null
                Exit Function
             Set Connect = swbemServices
             Exit Function
          End If
       Next
       Set Connect = Null
    End Function
    
    Function GetSMBIOSGUID
       Dim cimv2Namespace, results, record, SMBIOSGUID
    
       Set cimv2Namespace = GetObject ("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\.\root\cimv2") 
       Set results = cimv2Namespace.ExecQuery ("SELECT UUID FROM Win32_ComputerSystemProduct")
       
       For Each record in results 
          SMBIOSGUID = record.UUID
          If SMBIOSGUID = "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF" Or SMBIOSGUID = "00000000-0000-0000-0000-000000000000" Then
             SMBIOSGUID = ""
          End If
       Next
    
       GetSMBIOSGUID = SMBIOSGUID
    End Function
    
    Function GetResourceIDFromSMBIOSGUID(connection, SMBIOSGUID)
    
       query = "SELECT * FROM SMS_R_System WHERE SMS_R_System.SMBIOSGUID = """ & SMBIOSGUID & """"
    
       Set result = connection.ExecQuery(query)
       resourceID = 0
       
       For each r in result
          GetResourceIDFromSMBIOSGUID = r.ResourceID
       Next
    End Function
    
    Function MigrationState(connection, ResID)
    
       Dim migrations
       Dim migration
       
       Set migrations = connection.ExecQuery("SELECT SMS_StateMigration.RestoreClientResourceID FROM SMS_StateMigration WHERE SMS_StateMigration.RestoreClientResourceID = " & ResID)
    
       For Each migration in Migrations
          If migration.RestoreClientResourceID = ResID Then
             Env("Migration") = "Side-By-Side"
             Exit For
          End If
       Next
    
    End Function 
     
    

    If it does find something to restore then it sets a Task Sequence Variable called 'Migration' to 'Side-By-Side'. I then set a condition on the 'Restore user files and settings' task sequence so that it restores from the StateMigration point if Migration=Side-By-Side

     


    • Proposed as answer by WorkProfile Tuesday, October 11, 2011 1:41 PM
    • Edited by WorkProfile Tuesday, October 11, 2011 1:42 PM
    • Marked as answer by Garth JonesMVP Thursday, December 31, 2015 5:40 PM
    Tuesday, October 11, 2011 1:40 PM