top of page
  • Writer's pictureshishir kushawaha

MECM Cleanup Series: List Unused Imported Drivers

Microsoft Endpoint Configuration Manager (MECM) allows you to import device drivers into the MECM database and then deploy them to devices in your organization. However, over time, your collection of drivers can become bloated with outdated or unnecessary drivers. Finding out which drivers are not being used can help you clean up your driver repository and free up disk space.

To find out which imported device drivers are not being used in MECM, you can follow these steps:


Ensure you are not using 'Auto apply drivers' steps in any task sequence:

In some task sequences, 'Auto Apply Drivers' steps are used to automatically apply drivers during the deployment process. If you are using this method (rarely used), please avoid this method.


List drivers injected in boot image:

Boot images does contain some important drivers like network, storage etc. used during the WinPE phase of deployment. To find the list of drivers used in the boot image, navigate to the "Software Library" workspace in MECM and select "Operating Systems" > "Boot Images". Right-click on the boot image and select "Properties". In the "Properties" dialog box, select the "Drivers" tab to view the list of drivers used in the boot image.

(Get-CMBootImage | Select-Object -ExpandProperty ReferencedDrivers).id

List drivers which are part of driver packages:

Driver packages are used to deploy drivers to devices during the deployment process. To find the list of drivers used in driver packages, navigate to the "Software Library" workspace in MECM and select "Operating Systems" > "Driver Packages". Double click on driver package to view the list of drivers used in the package.

Get-CMDriverPackage -Fast | Select-Object packageid | % { (Get-CMDriver -Fast -DriverPackageId $_.packageid).ci_id}

Add boot image and drivers package drivers together:

After listing the drivers used in the boot image and driver packages, club them together to get a list of used drivers.


Find all imported drivers:

To find all drivers in MECM, navigate to the "Software Library" workspace in MECM and select "Operating Systems" > "Drivers". Here, you can view the list of all drivers imported in MECM.

get-cmdriver -fast

Deduct used drivers from all imported drivers:

Subtract the list of boot image drivers and driver package from the list of all imported drivers to get the list of unused drivers.


By following these steps, you can efficiently find out the list of unused drivers in MECM and remove them to optimize the driver store.


Please find the below script which will perform the above said activities:

$drivers= get-cmdriver -fast
$driverIDs= $drivers.ci_id

#list of driver packages
$driverpackageid=Get-CMDriverPackage -Fast | Select-Object packageid

#list of drivers integrated in boot image
$bootimageDriversIDs=(Get-CMBootImage | Select-Object -ExpandProperty ReferencedDrivers).id

$unusedDrivers=$null
$usedDrivers=@()

#list drivers from all driver packages
foreach($pkgid in $driverpackageid)
{
    $usedDrivers+=(Get-CMDriver -Fast -DriverPackageId $($pkgid.packageid)).ci_id
}
#Add boot image drivers in driver packages drivers
$usedDrivers+=$bootimageDriversIDs

#Remove duplicate drivers
$usedDrivers=$usedDrivers | Select-Object -Unique

#Subtract used drivers from all drivers to get the list if unused drivers
$drivers | ForEach-Object {if($_.ci_id -notin $usedDrivers){$unusedDrivers+=$_}}
"List of unused drivers"
$unusedDrivers 

You can also find the detailed code from Github.

Note: Please ensure that you thoroughly review the script before running it in your environment to ensure it aligns with your organization's policies and procedures.

Additional information about PowerShell command let used:

1,282 views0 comments

Recent Posts

See All

PowerShell Flow Control and Conditional Statements

PowerShell Flow Control and Conditional Statements are fundamental concepts that allow you to control the execution flow of your scripts based on specific conditions. They provide the flexibility to m

Comments


bottom of page