May 072013
 

The following PowerShell script will delete drivers from the driver store that match a keyword. It will also ignore a specific driver if need be. Use to prune older sets of drivers that are no longer needed. Use at your own risk, of course.

###########################################################################
#
# Use pnputil to delete drivers (in this case Xerox) from the driver store. 
#
# by Robert Hollingshead
# Contributed to the public domain. Do with it what you will. 
#
###########################################################################

# Populate the array. 
$arrayPnpOutput = & pnputil -e

for ($arrayPos=0;$arrayPos -le $arrayPnpOutput.length;$arrayPos++)
{
    if ($arrayPnpOutput[$arrayPos] -like "*Xerox") # Find matches for xerox as the publisher. ;
    {
        if ($arrayPnpOutput[$arrayPos+2] -notlike "*11/23/2011 5246.700*") # Do not kill this version..
        {
            $arrayPnpOutput[$arrayPos-1] = $arrayPnpOutput[$arrayPos-1] -replace "Published name :            ",""
            Write-Host "Erasing: " $arrayPnpOutput[$arrayPos-1]
            pnputil -d $arrayPnpOutput[$arrayPos-1]
        }
    }
}