As a follow up to my previous post, I also have developed a script to automate the import of drivers into MDT 2013. This PowerShell script takes a source folder structure and duplicates the top two levels of folders in the MDT Deployment Share “Out-of-box drivers ” branch. The script then imports all drivers found in the source directories to the matching folders in MDT.
All we have to do is extract all drivers for a given computer model into an appropriately named folder in the source directory, and then run the script.
################################################################################ # # Create-MDTDriverStructure.ps1 # J. Greg Mackinnon, University of Vermont, 2013-11-05 # Creates a folder structure in the "Out of Box Drivers" branch of a MDT 2013 # deployment share. The structure matches the first two subdirectories of # the source filesystem defined in $srcRoot. All drivers contained within # $srcRoot are imported into the deployment share. # # Requires: # $srcDir - A driver source directory, # $MDTRoot - a MDT 2013 deployment share # - MDT 2013 must be installed in the path noted in $modDir!!! # ################################################################################ # Define source driver directories: [string] $srcRoot = 'E:\staging\drivers\import' [string[]] $sources = gci -Attributes D $srcRoot | ` Select-Object -Property name | % {$_.name.tostring()} # Initialize MDT Working Environment: [string] $MDTRoot = 'E:\DevRoot' [string] $PSDriveName = 'DS100' [string] $oobRoot = $PSDriveName + ":\Out-Of-Box Drivers" [string] $modDir = ` 'C:\Program Files\Microsoft Deployment Toolkit\Bin\MicrosoftDeploymentToolkit.psd1' Import-Module $modDir New-PSDrive -Name "$PSDriveName" -PSProvider MDTProvider -Root $MDTRoot foreach ($source in $sources){ Write-Host "Working with source: " $source -ForegroundColor Magenta # Create the OOB Top-level folders: new-item -path $oobRoot -name $source -itemType "directory" -Verbose # Define a variable for the current working directory: $sub1 = $srcRoot + "\" + $source # Create an array containing the folders to be imported: $items = gci -Attributes D $sub1 | Select-Object -Property name | % {$_.name.tostring()} $oobDir = $oobRoot + "\" + $source foreach ($item in $items) { # Define source and target directories for driver import: [string] $dstDir = $oobDir + "\" + $item [string] $srcDir = $sub1 + "\" + $item # Clean up "cruft" files that lead to duplicate drivers in the share: Write-Host "Processing $item" -ForeGroundColor Green Write-Host "Cleaning extraneous files..." -ForegroundColor Cyan $delItems = gci -recurse -Include version.txt,release.dat,cachescrubbed.txt $srcDir Write-Host "Found " $delItems.count " files to delete..." -ForegroundColor Yellow $delItems | remove-Item -force -confirm:$false $delItems = gci -recurse -Include version.txt,release.dat,cachescrubbed.txt $srcDir Write-Host "New count for extraneous files: " $delItems.count -ForegroundColor Yellow # Create the target directory: Write-Host "Creating $item folder" -ForegroundColor Cyan new-item -path $oobDir -name $item -itemType "directory" -Verbose # Import all drivers from the source to the new target: Write-Host "Importing Drivers for $item" -ForegroundColor Cyan Import-MDTDriver -Path $dstDir -SourcePath $srcDir Write-Host "Moving to next directory..." -ForegroundColor Green } # End ForEach Item } # End ForEach Source Remove-PSDrive -Name "$PSDriveName"