You are here:   Research
  |  Login

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

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..."

# Integrate MDT with ConfigMgr
$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!

What our lawyers makes us say:

This information is provided "AS IS" with no warranties, confers no rights and is not supported by the authors or Deployment Artist.

Copyright © 2017 by Deployment Artist (the company behind deployment research). All rights reserved. No part of the information on this web site may be reproduced or posted in any form or by any means without the prior written permission of the publisher.

Shorthand: Don't pass off our work as yours, it's not nice.

Blog Archive