top of page
  • Writer's pictureshishir kushawaha

MECM Cleanup Series: List drivers with invalid source path

Microsoft Endpoint Configuration Manager (MECM) allows users to import drivers and create driver packages, which are used during image deployment through the Deployment Image Servicing and Management (DISM) tool. However, it is common for users to overlook the importance of regularly cleaning up these imported drivers, even if they become obsolete or corrupted.


For instance, consider a scenario where drivers have been imported for a specific device model, but later the model becomes obsolete and is no longer required or being used. Although the user may delete the driver package which is bundle of drivers for that specific model and its source path, they may forget to remove the obsolete drivers from the MECM console.


These corrupt or obsolete drivers may become useless and occupy valuable space in the MECM console and database. If any of these drivers are part of the boot image, they may also create issues during boot image updates, thereby adversely affecting the deployment process.


To address this issue, it is essential to regularly clean-up MECM drivers, especially those that are obsolete or corrupted. This can be achieved by removing the driver package and its source path from the console, and then deleting any obsolete or corrupt drivers from the driver source folder. By doing so, users can ensure that their driver packages are up-to-date, free of any corrupt or obsolete drivers, and improve the overall efficiency and performance of the image deployment process.


It is important to determine if the drivers to be cleaned up are linked to any boot image or driver package before proceeding. If they are, users must first unlink them. To identify these links or connections, you can refer to an existing blog.


Once the links have been removed, users can move on to identifying the list of corrupt drivers not having any data source path. You can use the PowerShell script provided below to accomplish this task.


#List all imported drivers
$driverInfo=Get-CMDriver -fast | Select-Object CI_ID,LocalizedDisplayName,CONTENTSOURCEPATH
$result = @()
$i=0
foreach($c in $driverInfo)
{
    $r=$true
    $e=$null
    #test existance of driver source path
    $r=Test-Path -LiteralPath "$($c.CONTENTSOURCEPATH)" -ErrorVariable e
    if($null -eq $e -or $e -eq "" -or $e.count -eq 0)
    {
        $m="Path does not exists."
     }
     else
     {
        $m=$($e -split '`n')
      }
    if($r -eq $false)
    {
        if($m -notmatch 'Access is denied')
        {
            $property=$null
            $property=$c |Select-Object ci_id,LocalizedDisplayName,CONTENTSOURCEPATH
            $newProperty = [ordered]@{}
            $newProperty."Sr No" = $i+1
            $newProperty."CI_ID" = $property.ci_id
            $newProperty."Name" = $property.LocalizedDisplayName
            $newProperty."Source Path" = $property.CONTENTSOURCEPATH
            $newProperty."Result" =  $m  
            $Objectname = New-Object PSobject -Property $newProperty
            $result += $Objectname
            $i++
        }
    }
}

Workflow of the script

  1. Script will first list all the drivers present in MECM.

  2. Then it will try to validate the path presence.

  3. Finally, it will list all drivers having invalid data source path and output will be generated in .HTML file like below.

Complete script is available at 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:


649 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