:::: MENU ::::
Monthly Archives: July 2018

Powershell Script for Installed driver details to export



param(
    [string]$outputFile
)

$dateTimeString = $(get-date -UFormat '%Y-%m-%d_%T.%S').Replace(':','')
if (! ($outputFile)) {
    $outputFile = "c:\temp\$($env:computername)--PnpSignedDrivers--$($dateTimeString).csv"
}

#$netBackupShare = '\\SHARE\PnPSignedDrivers'

$deviceIdIgnoreList= @(
    'Send To OneNote 2013',
    'WebEx Document Loader',
    'HTREE\ROOT\0',
    'Fax',
    'Microsoft Print to PDF',
    'Microsoft XPS Document Writer'
);

$selectObjectList = @(
    'DeviceClass',
    'Manufacturer',
    'DriverVersion',
#'DriverDate',
    @{Label='DriverDate';Expression={$_.ConvertToDateTime($_.DriverDate)}},
    'Description',
    'DeviceName',
    'FriendlyName',
    'CompatID',
    'DeviceID',
    'HardWareID',
    'DevLoader',
    'DriverName',
    'DriverProviderName',
    'InfName',
    'InstallDate',
    'IsSigned',
    'Signer'
);

Write-Host ''
Write-Host 'Pulling PnP Signed Drivers from WMI ...'
$wmiClass = 'Win32_PnPSignedDriver'
$drivers = Get-WmiObject $wmiClass | 
    Where-Object { !($deviceIdIgnoreList.Contains($_.DeviceID)) } |
    Select-Object $selectObjectList |
        Sort-Object Manufacturer,DeviceClass,Description

if ($drivers) {
    Write-Host ''
    Write-Host 'Exporting results to .CSV ...'
        $drivers | Export-Csv -Path $outputFile

    Write-Host '--> Cleaning up .CSV ...'
    $fileBuffer = Get-Content -Path $outputFile | Select -Skip 1
    Set-Content -Path $outputFile -Value $fileBuffer

    Write-Host ''
    Write-Host "Final output file is located at:`r`n   `"$($outputFile)`""

   # Copy-Item $outputFile "$($netBackupShare)\"
#    Write-Host ''
   # Write-Host "File has also been backed up to:`r`n   $($netBackupShare)\"
} else {
    Write-Host ''
    Write-Host "No driver '$($wmiClass)' was found."
}