2017-04-16 47 views

回答

1

对我来说,这在IPs罚款。在PowerShell中使用foreach有一个更简单的方法。
并删除Format-Table;写入主机时非常有用,但将nslookup结果转换为Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData数据类型。
使用-AppendOut-File以避免覆盖以前的结果。

$ipAddress = @('107.20.253.26', '107.20.178.220', '8.8.8.8') 

foreach($ip in $ipAddress) { 

    # remove Format-Table 
    $resolve = nslookup $ip 

    # Add Append flag so that you are not overwriting previous contents on each loop 
    $resolve | Out-File $resolveFile -Append 

} 
+0

伟大的解决方案。非常感谢你。这工作真的很好,毫不费力。 – 9009

相关问题