When migrating from SMS2003 or another deployment solution to SCCM 2007/MDT, one of the challenges are to import the computers into the MDT database so they are present when a computer needs to be re-installation is necessary. Michael Niehaus have written a great article and powershell cmdlet which I have used a couple of times now and it works great, you can download it here at Michael Niehaus blogg.
This is an example of how to do it:
- Create a report in the new SCCM environment which contains the clients which needs importing into the MDT database, with name and UUID.
- Export it to a CSV file
- Remove all entries with blank if any UUID.
- Add roles to be imported for the computers in the CSV file, for instance roles used during deployment perhaps OS version. In this example two columns for roles as displayed in the example below:
Name,UUID,Role1,Role2
Client1,9B927E08-E490-4B78-9AD4-D38E4ACBF19C,”Windows7″,”HR”
Client2,81DFEB96-4880-41C6-8310-C09AC8039772,”WindowsXP”
- Then import the CSV file using powershell script
- The powershellscript in this example will do the following:
- Import the computer and UUID, if the UUID doesn’t already exist in the MDT database
- Add the roles to the imported object.
As always test the script in a test-environment before using it in production!:
Import-Module –name C:\MDTDB.psm1
Connect-MDTDatabase –sqlServer SCCM1 –database Deployment
$machines = Import-Csv C:\mdtimport.CSV
For ($i=1; $i -le $machines.count; $i++)
{
$machineid = get-mdtcomputer -uuid $machines[$i-1].uuid
if ($machineid -eq $NULL)
{
“New machine”
New-MDTComputer -uuid $machines[$i-1].uuid -description $machines[$i-1].name -settings @{
OSDComputerName=$machines[$i-1].name;
OSInstall=’YES’;
Computername=$machines[$i-1].name}
$machineid = get-mdtcomputer -uuid $machines[$i-1].uuid
set-mdtcomputerrole $machineid.id $machines[$i-1].role1 , $machines[$i-1].role2
}
}
Then you are ready to install computers using your new SCCM+MDT environment.