PowerShell实战1:Ping_Test
来源:互联网 发布:mac book音乐剪辑软件 编辑:程序博客网 时间:2024/05/05 11:37
功能:批量测试远程主机的Ping值,以及根据TTL值来判断是否为Windows主机。
使用:在C:/IP.txt中加入需要测试的主机IP或域名,一行一个。例如:
使用:在C:/IP.txt中加入需要测试的主机IP或域名,一行一个。例如:
源码:www.google.com
www.baidu.com
www.cha123.com
www.yahoo.com
www.msn.com
结果:function Ping_Test {
PROCESS {
$ping = $false
$results = Get-WmiObject -query `
"SELECT * FROM Win32_PingStatus WHERE Address = '$_'"
$RT = $results.ResponseTime
$TTL = $results.ResponseTimeToLive
foreach ($result in $results) {
if ($results.StatusCode -eq 0) {
if ($TTL -ge 98 -and $TTL -le 128)
{Write-Host "`n$_ Response Time=$RT ms, TTL=$TTL,It is a Windows host." -ForegroundColor Green }
else
{Write-Host "`n$_ Response Time=$RT ms, TTL=$TTL, It is NOT a Windows host." -ForegroundColor Blue}
}
else {
Write-Host "`n$_ Ping failed!" -ForegroundColor Red
}
}
}
}
cls
Get-Content c:/IP.txt | Ping_Test
本文出自 “面朝大海,春暖花开” 博客,谢绝转载!
- PowerShell实战1:Ping_Test
- PowerShell 工作流实战1
- Powershell 工作流实战(1)
- PowerShell实战2:Remote_Host
- windows PowerShell 实战指南 读后感
- Windows PowerShell 实战指南-附录(复习实验)-实验回顾1
- PowerShell实战3:IAS服务器认证日志
- PowerShell实战 第五回 创建HAB
- 《windows PowerShell 实战指南》试读后感
- Powershell快速入门(三) 实战应用
- Windows PowerShell 实战指南-动手实验-3.8
- Windows PowerShell 实战指南-动手实验-4.10
- Windows PowerShell 实战指南-动手实验-5.7
- Windows PowerShell 实战指南-动手实验-6.7
- Windows PowerShell 实战指南-动手实验-8.10
- Windows PowerShell 实战指南-动手实验-9.8
- Windows PowerShell 实战指南-动手实验-10.10
- Windows PowerShell 实战指南-动手实验-11.7
- RH133 Unit 11 Troubleshooting
- RH133 Unit 10 Virtualization with Xen
- RH133 Unit 9 Installation
- RH133 Unit 8 Network Configuration
- PowerShell实战2:Remote_Host
- PowerShell实战1:Ping_Test
- XP客户端和域控之间安全通道损坏的解决办法
- XenServer虚拟机Promiscuous模式配置
- CentOS桌面安装和选择
- CentOS共享打印机失败一例
- ESXi的路由特性
- 交换机环路问题一例
- Ubuntu中配置Cisco VPN客户端一例
- IT监控专题