Thursday, November 21, 2019

Extracting Microsoft Surface Drivers

For the Surface Pro 6 I ended up downloading four .msi files and needed to extract them to get the drivers for import into SCCM.  I wrote this little PowerShell script to iterate through all four and extract them for me complete with logs in case anything went wrong.  Figured I would post it here in case anyone else finds it useful.


#Extract-MSIFiles.PS1
#Creates folders for each .msi and extracts contents into the folders
#By Mark Randol - randoltech.blogspot.com

$BasePath = "C:\Users\me\Downloads\Drivers\Surface Pro 6 1796 Commercial"

Start-Transcript -Path "$BasePath\Extract-MSIFiles.log" -Force

$SearchPath = $BasePath + "\*"
$MSIFiles = Get-ChildItem $SearchPath -Include *.msi
foreach ($File in $MSIFiles) {
    $FileName = $File.Name
    New-Item -Path "$BasePath" -Name $File.BaseName -ItemType "Directory"
    $ExtractFolder = $BasePath + "\" + $File.BaseName
    $ArguementString = "/a ""$BasePath" + "\" + "$Filename"" targetdir=""$ExtractFolder"" /l*v ""$BasePath\$FileName.log"" /qn"
    Start-Process -FilePath "msiexec.exe" -ArgumentList $ArguementString
    Wait-Process -Name msiexec -Timeout 90
}

Stop-Transcript



-Enjoy

Wednesday, November 6, 2019

Detection Method for an APPX package

None of the standard SCCM application detection methods work for APPX packages.  For an APPX package use "Use a custom script to detect the presence of this deployment type" and this command line as the script (modify for the package name and version number that you need obviously):

if ([version]((Get-AppxPackage *AppUp.ThunderboltControlCenter*).Version) -ge ([version]("1.41.648.5"))) { write-output $true }

Enjoy!