Expand-OSDriver.ps1
<#
.LINK https://www.osdeploy.com/psmodule/osdrivers/ .SYNOPSIS Option to expand compressed drivers and to cleanup Nvidia Drivers .DESCRIPTION Optionally expands compressed drivers. Optionally removes Nvidia Driver junk .PARAMETER Path Directory containing Drivers .PARAMETER ExpandCompressedFiles Expands compressed files *.bi,*.cf,*.cp,*.dl,*.ex,*.hl,*.pd,*.sy,*.tv,*.xm .PARAMETER NvidiaCleanup Removes directories named Display.NView, Display.Optimus, Display.Update, DisplayDriverCrashAnalyzer, GFExperience, GFExperience.NvStreamSrv, MSVCRT, nodejs, NV3DVision, NvBackend, NvCamera, NvContainer, NVI2, NvTelemetry, NVWMI, PhysX, ShadowPlay, Update.Core .EXAMPLE Expand-OSDriver -Path C:\Temp\Nvidia -ExpandCompressedFiles -NvidiaCleanup .NOTES NAME: Expand-OSDriver.ps1 AUTHOR: David Segura, david@segura.org BLOG: http://www.osdeploy.com CREATED: 02/17/2018 VERSION: 1.1.0.1 #> function Expand-OSDriver { [CmdletBinding()] Param ( [Parameter(Mandatory=$True)] [string]$Path, [switch]$ExpandCompressedFiles, [switch]$NvidiaCleanup ) Write-Host "***** Calculating Path Size *****" $SizeStart = "{0:N2} GB" -f ((Get-ChildItem $Path -Recurse | Measure-Object -Property Length -Sum -ErrorAction Stop).Sum / 1GB) if ($ExpandCompressedFiles) { Write-Host "***** Expanding Files *****" Get-ChildItem -Path $Path -Include *.*_ -Recurse | ForEach ($_) { expand -r $_.FullName Remove-Item $_.FullName } #Rename Expanded Files Get-ChildItem -Path $Path -Include *.bi,*.cf,*.cp,*.dl,*.ex,*.hl,*.pd,*.sy,*.tv,*.xm -Recurse | ForEach ($_) { $NewName=$_.Name.Replace(".bi",".bin") $NewName=$NewName.Replace(".cf",".cfg") $NewName=$NewName.Replace(".cp",".cpl") $NewName=$NewName.Replace(".dl",".dll") $NewName=$NewName.Replace(".ex",".exe") $NewName=$NewName.Replace(".hl",".hlp") $NewName=$NewName.Replace(".pd",".pdf") $NewName=$NewName.Replace(".sy",".sys") $NewName=$NewName.Replace(".tv",".tvp") $NewName=$NewName.Replace(".xm",".xml") Rename-Item $_.FullName -NewName $NewName } Write-Host "***** Calculating Path Size *****" $SizeExpanded = "{0:N2} GB" -f ((Get-ChildItem $Path -Recurse | Measure-Object -Property Length -Sum -ErrorAction Stop).Sum / 1GB) } if ($NvidiaCleanup) { $Remove = "Display.NView", "Display.Optimus", "Display.Update", "DisplayDriverCrashAnalyzer", "GFExperience", "GFExperience.NvStreamSrv", "MSVCRT", "nodejs", "NV3DVision", "NvBackend", "NvCamera", "NvContainer", "NVI2", "NvTelemetry", "NVWMI", "PhysX", "ShadowPlay", "Update.Core" ForEach ($Dir in $Remove) { Write-Host "***** Removing Directories Named $Dir *****" Remove-Item -Path $Path -Include $Dir -Recurse } Write-Host "***** Calculating Path Size *****" $SizeDeJunked = "{0:N2} GB" -f ((Get-ChildItem $Path -Recurse | Measure-Object -Property Length -Sum -ErrorAction Stop).Sum / 1GB) } Write-Host "Initial Size: " $SizeStart if ($ExpandCompressedFiles) {Write-Host "Expanded Size: " $SizeExpanded} if ($NvidiaCleanup) {Write-Host "De-Junked Size: " $SizeDeJunked} } |