Home TechIT Stuff Export Windows Drivers to Central Store

Export Windows Drivers to Central Store

by padd

Just made a script to export Drivers to a central store. Handy for when you need to grab a the drivers off of a PC to look at later or to update the rest of the estate with.

Link to resource on Spiceworks: https://community.spiceworks.com/scripts/show/3689-export-drivers-to-central-store

##########################################
###                                    ###
###         Script to extract          ###
###         latest drivers from        ###
###         windows system and         ###
###         dump to central store      ###
###                                    ###
### By Patrick Louis-Jean     v1       ###
##########################################


### Variables ###
$CentralStore = "\\server\Shares\Drivers" #Where Drivers will be stored centrally
$LocalStore = "C:\Drivers" #working folder on local machine

### Showtime! ###
$SystemOS = (Get-WmiObject -class Win32_OperatingSystem).Caption
$ComputerMake = "$((Get-WmiObject -Class win32_computersystem).Manufacturer)"
$DateTime = Get-date -Format yyyy-MM
$DriverStore = "$LocalStore\$SystemOS\$ComputerMake $((Get-WmiObject -Class win32_computersystem).Model) $DateTime"
mkdir $DriverStore
cd $DriverStore
$DriversList = Export-WindowsDriver -Online -Destination $DriverStore

foreach ($Driver in $DriversList) {
    #Make Class Directory
    $ClassDirectory = $DriverStore+"\"+$Driver.ClassName
    if (!(Test-Path $ClassDirectory)){
                 New-Item $ClassDirectory -type directory
    }
    #Make Provider Directory
    $ProviderDirectory = $ClassDirectory+"\"+$Driver.ProviderName
    if (!(Test-Path $ProviderDirectory)){
                 New-Item $ProviderDirectory -type directory
    }
    #Move Drivers to Folder
        #Get Original Folder Name
        $OrigDriverFolder = $Driver.OriginalFileName
        $OrigDriverFolder = $OrigDriverFolder.replace("C:\Windows\System32\DriverStore\FileRepository\","") #Assuming all drivers are stored here!
        $position = $OrigDriverFolder.IndexOf("\")
        $OrigDriverFolder = $OrigDriverFolder.Substring(0,$position)
        $OrigDriverFolder
        #Make New Folder Name
        $NewDriverFolder = $ProviderDirectory+"\"+$OrigDriverFolder+"_v"+$Driver.Version
        $NewDriverFolder
        #Move Folder
        robocopy $DriverStore"\"$OrigDriverFolder $NewDriverFolder /E /MOVE /NP
}

#Output List of Drivers to CSVFile
$DriversList | Select OriginalFileName, ClassName, ClassDescription, ProviderName, Version |Sort-Object OriginalFileName |  Export-Csv -Path $DriverStore"\DriverList.csv" -NoTypeInformation

#Move to Central Store
robocopy $LocalStore $CentralStore /E /MOVE /NP

You may also like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.