OSD Driver installation via PowerShell

Today we are going to install the model-specific driver packages using PowerShell script. The advantage of using this method of driver installation during the Operating System deployment is to reduce the overall Task Sequence deployment time, This method is more suitable if you have multiple hardware devices with multiple vendors (Dell, HP, Lenovo, Microsoft, etc...) 

In order to achieve this method follow the below steps. 

1. Create the folder structure as below.
        a. Vendor\Hardware model\

2. Download the specific hardware model driver package from the vendor website and extract the cab files.

3. Archive/Zip all the extracted drivers into one single folder called "Drivers.zip".

4. Copy DISM folder from ADK installed machine and place into the "Vendor\Hardware model\"
path of DISM-(C:\Program Files (x86)\Windows Kits\<version>\Assessment and Deployment Kit\Deployment Tools\10\DISM)

5. Download the 7za.exe and place it(7za.dll, 7za.exe, and 7zxa.dll) into the "Vendor\Hardware model\".

6. Create the PowerShell script using the below code and save it as "InjectDrivers.ps1".
Easy and faster way to install OSD Driver through PowerShell









<#

    .SYNOPSIS

    Driver installation in an easy and faster way using PowerShell script.

    .DESCRIPTION

    This script will install the hardware model drivers in a faster and easy way while Task Sequence execution and help OSD administrators to reduce the overall installation time and make life easy.

    .NOTES

    =============================================================================================================================================

    Created with:     Windows PowerShell ISE

    Created on:       Tuesday, August 17, 2022, 2:05:44 PM

    Created by:       Dashrath Chate

    Organization:     Blogger

  =============================================================================================================================================

#>

$TSEnvironment = New-Object -COMObject Microsoft.SMS.TSEnvironment

$SMSTSLogPath = $TSEnvironment.Value("_SMSTSLogPath")

$OSDrive = "C:\"

#Set the folder where Driver will be extracted

$DriversExtracted = $OSDrive + "\Windows\Temp\Drivers\"

mkdir $DriversExtracted -Force

#Extract the Drivers

&$PSScriptRoot\Files\7za.exe x $PSScriptRoot\Drivers.zip  -y -o"$DriversExtracted"

#Load the DISM Drivers

&$PSScriptRoot\Files\DISM\wimmountadksetupamd64.exe /Install /q

#Run DISM

&$PSScriptRoot\Files\DISM\DISM.exe /Image:$OSDrive /Add-Driver /Driver:$DriversExtracted /Recurse /LogPath:$SMSTSLogPath\DISM_DriverInjection.log 

#Cleanup Drivers

RMDIR $DriversExtracted -Recurse -Force

7. Create the normal SCCM package and distribute it on required DPs and use and use in the Task sequence as shown in the below image.

Task Sequence Driver Installation PowerShell Step
















8. While the package is executing during the Task Sequence execution, the lo file will create in the CCM\logs folder named "DISM_DriverInjection.log"

DISM_DriverInjection.log












9. Build the reference machine and test the solution !!!

No comments:

Post a Comment

Leave your valuable words here for improve better.