【问题标题】:IP Scan Power Shell ScriptIP 扫描 Powershell 脚本
【发布时间】:2019-03-28 07:25:27
【问题描述】:

我正在尝试创建一个 powershell 脚本,通过输入第一个和最后一个八位字节来 ping 一系列 IP。如果使用Write-host,则脚本的其余部分将不会执行。如果使用写入输出,.. 就不能作为序列工作

$StartIP = Read-Host -Prompt 'Input Start IP'

$EndIP = Read-Host -Prompt 'Input End IP'

Write-output $StartIP..$EndIP | % {"192.168.128.$($_): $(Test-Connection -count 1 -comp 192.168.128.$($_) -quiet)"}

【问题讨论】:

    标签: powershell


    【解决方案1】:

    您需要将其括在括号中:

    Write-output ($StartIP..$EndIP) | % {"192.168.128.$($_): $(Test-Connection -count 1 -comp 192.168.128.$($_) -quiet)"}
    

    如果您省略 Write-Output,您可以简单地使用:

    $StartIP..$EndIP | % {"192.168.1.$($_): $(Test-Connection -count 1 -comp 192.168.1.$($_) -quiet)"}
    

    【讨论】:

    • 工作完美!现在我试图得到回复,绿色为真,红色为假。任何帮助都会很棒
    • 请为@papa0s0 开一个新问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-18
    • 2015-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-16
    • 1970-01-01
    相关资源
    最近更新 更多