Yet another blog post I need to recreate thanks to the vagaries of moving WordPress between hosters 🙁
This code lets you import device drivers into Configuration Manager, as per the steps laid out in Chapter 11 of Learn ConfigMgr 2012 in a Month of Lunches.
You can also download the code directly from //www.jamesbannanit.com/files/manning/CMDriverImport.zip
# Define Configuration Manager variables
$CMSiteCode = 'P01'
$CMSiteServer = 'LAB-CM01.mol.sccmlab.net'
$CMNameSpace = "root\SMS\site_$CMSiteCode"
$DriverPackageName = 'Dell Latitude E6530 – Windows 8.1 x64 - A01'
$DriverPackageSource = '\\lab-cm01\Sources\Driver Packages\Dell Latitude E6530 - Windows 8.1 x64 - A01'
$DriverSource = '\\lab-cm01\Sources\Drivers\Dell Latitude E6530\Windows 8.1 x64'
$DriverCategoryName01 = 'Windows 8.1 x64'
$DriverCategoryName02 = 'Dell Latitude E6530'
# 1.0 Create Driver Package
New-CMDriverPackage -Name $DriverPackageName -Path $DriverPackageSource -Verbose
$DriverPackage = Get-CMDriverPackage -Name $DriverPackageName
Start-CMContentDistribution -DriverPackageName $DriverPackage.Name -DistributionPointName $CMSiteServer -Verbose
# 1.1 Create Administrative Categories
If ((Get-CMCategory -Name $DriverCategoryName01) -eq $null) {
New-CMCategory -CategoryType DriverCategories -Name $DriverCategoryName01
}
$DriverCategory01 = Get-CMCategory -Name $DriverCategoryName01
If ((Get-CMCategory -Name $DriverCategoryName02) -eq $null) {
New-CMCategory -CategoryType DriverCategories -Name $DriverCategoryName02
}
$DriverCategory02 = Get-CMCategory -Name $DriverCategoryName02
# 1.2 Build Category array
$DriverCategories = @()
$DriverCategories += $DriverCategory01
$DriverCategories += $DriverCategory02
# 1.3 Get Drivers
Set-Location C:
$Drivers = Get-ChildItem -Path $DriverSource -Include *.inf -Recurse
Set-Location ($CMSiteCode + ':')
# 1.4 Import Drivers
foreach ($driver in $drivers){
Import-CMDriver -UncFileLocation $Driver.FullName `
-DriverPackage $DriverPackage `
-EnableAndAllowInstall $true `
-AdministrativeCategory $DriverCategories `
-ImportDuplicateDriverOption AppendCategory `
-ErrorAction SilentlyContinue `
-Verbose
}
Hi James,
Probably changed in R2, Needed to add -PackageSourceType to create the driver package. Also code to to load the ConfigMgr PSDrive.
import-module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + ‘\ConfigurationManager.psd1’)
$PSD = Get-PSDrive -PSProvider CMSite
# 1.0 Create Driver Package
CD “$($PSD):”
New-CMDriverPackage -Name $DriverPackageName -Path $DriverPackageSource -PackageSourceType StorageDirect -Verbose
//dl.dropboxusercontent.com/u/4831681/importdrivers.ps1