+-
利用PowerShell创建SCCM package升级Intel WIFI驱动

Intel时不时的发布新的Wifi驱动包来修复一些安全和稳定相关的问题,如下面这个advisory。

https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00448.html

一般来说,Intel的Wifi驱动对于各个OEM厂商来说都是通用的,不必非要去OEM厂商为每个型号都下载一个单独的驱动,现在就来说一下如何创建一个通用的Wifi驱动升级包。

Intel官网下载驱动包

要下载 "Drivers for IT Admins", 用7zip解压

       https://downloadcenter.intel.com/download/30280/Intel-PROSet-Wireless-Software-and-Drivers-for-IT-Admins

  2. 创建PowerShell 脚本

       驱动的升级需要利用PowerShell脚本调用devcon来实现

       安装WDK并获取devcon.exe

       创建脚本获取WIFI的硬件ID,match对用的inf文件并调用devcon来执行静默升级

       代码如下

<#
.NOTES
===========================================================================
 Created with: 	SAPIEN Technologies, Inc., PowerShell Studio 2019 v5.6.166
 Created on:   	12/10/2019 1:50 PM
 Created by:   	sky2133
 Organization: 
 Filename:     	Update-WiFi.ps1
===========================================================================
.DESCRIPTION
Upgrade WiFi driver by utilizing DevCon from WDK
#>
Function Write-Log
{
[cmdletbinding()]
Param (
[Parameter(Position = 0)]
[ValidateNotNullOrEmpty()]
[string]$Message,
[Parameter(Position = 1)]
[string]$LogPath = "$env:windir\Deployments\Update-WiFi.log"
)

#Pass on the message to Write-Verbose if -Verbose was detected
Write-Verbose $Message

#only write to the log file if the $LoggingPreference variable is set to Continue

#if a $loggingFilePreference variable is found in the scope
#hierarchy then use that value for the file, otherwise use the default
#$LogPath
if ($loggingFilePreference)
{
$LogFile = $loggingFilePreference
}
else
{
$LogFile = $LogPath
}

Write-Output "$(Get-Date) - $Message" | Out-File -FilePath $LogFile -Append

} #end function

Write-Log "Script starting to run"
write-log "................................................................................................................"
gci c:\Windows\System32\drivers\netw*.sys | % {

Write-Log "Driver File: $($_.name)"
Write-Log "Driver Version: $($(Get-ItemProperty $_).VersionInfo.Fileversion)"
}
$wifi = get-netadapter -Name Wi-Fi | select -ExpandProperty PnPDeviceID | select -First 1
$wifi_sub = $wifi.substring(22, 15)
$wifi = $wifi.substring(0, 37)

gci *.inf | select -ExpandProperty fullname | % {
if ($(gc $_) -match $wifi_sub)
{
write-log "driver matched $wifi, start to upgrade...."
.\devcon update $_  $wifi
}

}
write-log "driver matched $wifi, upgrade completed"

write-log "................................................................................................................"

gci c:\Windows\System32\drivers\netw*.sys | % {

Write-Log "Driver File: $($_.name)"
Write-Log "Driver Version: $($(Get-ItemProperty $_).VersionInfo.Fileversion)"
}

此时的目录结构如下










3. 创建SCCM Package

设置好相关属性和文件路径















执行命令设置如下

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -noprofile -noninteractive -executionpolicy bypass -windowstyle hidden -command ".\update-wifi.ps1"















4. 推送安装并测试安装结果

安装完成后可以到设备管理器看下WIFI的驱动版本,有什么问题的话,可以打开日志文件"C:\windows\Deployments\Update-WiFi.log" 看下具体的执行情况。