一. 知识点
netsh wlan show profiles
Measure-Object
[PSCustomObject]@{ }
[math]::Round
Write-Progress
二. 代码
- 只能获取中文Windows操作系统的wifi密码
- 如果想获取英文获取日文,需要把
Select-String
后面的汉字改为对应系统的语言的文字
Write-Host '脚本执行开始...' -ForegroundColor Red
$wifi_name_list = netsh wlan show profiles | Select-String "所有用户配置文件" | ForEach-Object {$_ -replace ".*:\s+", ""
}
$wifi_list_count = ($wifi_name_list | Measure-Object).Count
$wifi_object_array = @()
for ($i = 1; $i -le $wifi_list_count; $i++) {$wifi_object_array += [PSCustomObject]@{wifi名称 = $wifi_name_list[$i]wifi密码 = netsh wlan show profile name="$($wifi_name_list[$i])" key=clear | Select-String "关键内容" | ForEach-Object { $_ -replace ".*:\s+", "" }}$progress = [math]::Round(($i / $wifi_list_count) * 100)Write-Progress -Activity "ヾ(•ω•`)oWiFi密码获取ヾ(•ω•`)o" -Status "当前进度: $progress%" -PercentComplete $progress
}
Write-Progress -Activity "ヾ(•ω•`)oWiFi密码获取ヾ(•ω•`)o" -Status "Completed!" -Completed
$wifi_object_array | Format-Table -AutoSizeWrite-Host '脚本执行结束...' -ForegroundColor Red
Pause
三. 效果
