Skip to content

Instantly share code, notes, and snippets.

@milesgratz
Created April 17, 2017 17:50
Show Gist options
  • Save milesgratz/9b89999d2f4b54eb1ccdb539abaa3441 to your computer and use it in GitHub Desktop.
Save milesgratz/9b89999d2f4b54eb1ccdb539abaa3441 to your computer and use it in GitHub Desktop.
Example to expand and install driver cabs
$CabPath = "C:\temp"
$CabFiles = Get-ChildItem $CabPath\*.cab
# Expand Cabs into folder based on their Name
foreach ($Cab in $CabFiles){
$Directory = New-Item -Path $CabPath\$($Cab.BaseName) -ItemType Directory -Force
expand $Cab.FullName -F:* $Directory.FullName
}
# Install drivers inside each cab
foreach ($Cab in $CabFiles){
$infs = Get-ChildItem -Path $CabPath\$($Cab.BaseName) -Filter "*.inf" -Recurse -File
foreach($inf in $infs){
Write-Host Installing $inf.FullName
pnputil.exe -i -a ""$inf.FullName""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment