CmdLets/Install-Drivers.ps1
|
Function Install-Drivers { [CmdletBinding()] Param( [Parameter(Mandatory=$True)] [System.IO.FileInfo]$Path ) #Import Publisher Certificates if they exist Get-ChildItem (Join-Path $Path "*.cer") -Recurse | ForEach-Object { $Cert.Import($_.FullName) If (!(Test-Path "Cert:\LocalMachine\TrustedPublisher\$($Cert.Thumbprint)")) { Import-Certificate $_.FullName -CertStoreLocation Cert:\LocalMachine\TrustedPublisher; } } #Install Driver $INFs = Get-ChildItem (Join-Path $Path *.inf) -Recurse $INFs | ForEach-Object { $i++; Write-Progress -ID 0 -Activity "Installing Drivers" -Status "Installing $i of $($INFs.Count): $($_.Name)" -PercentComplete (($i/$INFs.Count)*100); PnPUtil.exe /add-driver "$($_.FullName)" /install /subdirs } Write-Progress -ID 0 -Activity "Installing Drivers" -Completed } |