You are here:   Research
  |  Login

Welcome to my blog, quickest way to find articles is usually to search for them.

Minimize
Search in All Title Contents
 
     

Quick tip - PowerShell script to integrate MDT with ConfigMgr

Dec 17 2016

Here is a PowerShell script that integrate MDT with ConfigMgr.

Creds: Special thanks goes to Peter Hinchley (@hinchley) for the initial version.

 

The Script

Here is the script, have fun :)

# Check for elevation
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
    [Security.Principal.WindowsBuiltInRole] "Administrator"))
{
    Write-Warning "Oupps, you need to run this script from an elevated PowerShell prompt!`nPlease start the PowerShell prompt as an Administrator and re-run the script."
    Write-Warning "Aborting script..."
    Throw
}

# Integrate MDT with ConfigMgr
$SiteServer = "$env:COMPUTERNAME.$env:USERDNSDOMAIN"
$SiteCode = (Get-WmiObject -ComputerName $SiteServer -Namespace "root\SMS" -Class "SMS_ProviderLocation").SiteCode
$MDTInstallDir = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Deployment 4' -Name Install_Dir).Install_Dir

# Getting CM console installation folder via registry, because the $env:SMS_ADMIN_UI_PATH method requires console to be started once
$CMConsoleInstallDir = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\SMS\Setup' -Name 'UI Installation Directory').'UI Installation Directory'
$MOF  = "$CMConsoleInstallDir\Bin\Microsoft.BDD.CM12Actions.mof"

Copy-Item "$MDTInstallDir\Bin\Microsoft.BDD.CM12Actions.dll" "$CMConsoleInstallDir\Bin\Microsoft.BDD.CM12Actions.dll"  
Copy-Item "$MDTInstallDir\Bin\Microsoft.BDD.Workbench.dll" "$CMConsoleInstallDir\Bin\Microsoft.BDD.Workbench.dll"  
Copy-Item "$MDTInstallDir\Bin\Microsoft.BDD.ConfigManager.dll" "$CMConsoleInstallDir\Bin\Microsoft.BDD.ConfigManager.dll"  
Copy-Item "$MDTInstallDir\Bin\Microsoft.BDD.CM12Wizards.dll" "$CMConsoleInstallDir\Bin\Microsoft.BDD.CM12Wizards.dll"  
Copy-Item "$MDTInstallDir\Bin\Microsoft.BDD.PSSnapIn.dll" "$CMConsoleInstallDir\Bin\Microsoft.BDD.PSSnapIn.dll"  
Copy-Item "$MDTInstallDir\Bin\Microsoft.BDD.Core.dll" "$CMConsoleInstallDir\Bin\Microsoft.BDD.Core.dll"  
Copy-Item "$MDTInstallDir\SCCM\Microsoft.BDD.CM12Actions.mof" $MOF  
Copy-Item "$MDTInstallDir\Templates\CM12Extensions\*" "$CMConsoleInstallDir\XmlStorage\Extensions\" -Force -Recurse  
(Get-Content $MOF).Replace('%SMSSERVER%', $SiteServer).Replace('%SMSSITECODE%', $SiteCode) | Set-Content $MOF | Out-Null
& "C:\Windows\System32\wbem\mofcomp.exe" "$CMConsoleInstallDir\Bin\Microsoft.BDD.CM12Actions.mof" | Out-Null

 

Written by Johan Arwidmark








Happy deployment, and thanks for reading!
/ The Deployment Research team



Ami Casto

Johan Arwidmark

Blog Archive

Minimize