利用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