利用PowerShell建立SCCM package升级Intel WIFI驱动

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

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

通常来讲,Intel的Wifi驱动对于各个OEM厂商来讲都是通用的,没必要非要去OEM厂商为每一个型号都下载一个单独的驱动,如今就来讲一下如何建立一个通用的Wifi驱动升级包。
windows

  1. Intel官网下载驱动包安全

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

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

  2. 建立PowerShell 脚本测试

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

       安装WDK并获取devcon.exe日志

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

       代码以下

<#	
	.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)"
}

此时的目录结构以下

image.png










3. 建立SCCM Package

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

image.png















执行命令设置以下

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



image.png













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

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



image.png