adb 列出手机 id 列表
# 列出所有显示 device 的编号
.\adb.exe devices |
? { $_ -match '\bdevice\b' } | # 列出显示为 device 手机
Select-String '.*(?=\t)' | ForEach-Object { ($_.Matches.Value) } # 解析出 id
# 列出 ip 手机
.\adb.exe devices |
? { $_ -match '\bdevice\b' } | # 列出显示为 device 手机
Select-String '.*(?=\t)' | ForEach-Object { ($_.Matches.Value) } | # 解析出 id
? { $_ -like '*:*'} # 过滤出 ip 手机
# 连接 ip 手机
1..80 | % { .\adb.exe connect "10.10.104.$($_):6667" }
# ping ip 手机
.\adb.exe devices |
Select-String '.*(?=\t)' | ForEach-Object { ($_.Matches.Value) } | ? { $_ -like '*:*'} |
% { Write-Host $_ -ForegroundColor Green; Invoke-Expression ".\adb.exe -s $_ shell 'ping -c 2 www.baidu.com'" }