function Get-DriverFiles {
param (
[string]$searchPath
)
# 获取目录下所有.sys文件
$files = Get-ChildItem -Path $searchPath -Filter *.sys -Recurse | Where-Object { -not $_.PSIsContainer }
# 创建空数组来存储匹配的文件路径
$matchedFiles = @()
$matchedPaths = @()
# 遍历
foreach ($file in $files) {
$matchedPaths += $file.FullName
$matchedFiles += $file.Name
}
# 输出结果,确保不包含重复文件名
# 不重复输出文件名
$matchedFiles | Select-Object -Unique | ForEach-Object { Write-Output $_ }
Write-Host ""
# 输出所有的驱动文件路径
$matchedPaths | ForEach-Object { Write-Output $_ }
}
# 调用函数
$driverPath = "C:\Program Files (x86)\360" # 递归目录
Get-DriverFiles -searchPath $driverPath
该 powershell 代码支持 win7 及以上系统
360 的 驱动文件一般在两个位置:
1. 安装目录;
2. C:\Windows\System32\drivers 目录;