我有一个PowerShell脚本,该脚本运行在一台计算机列表中,并检查是否有多个网络接口。 (它将列出每台计算机的IP地址)
如果为每台计算机指定了多个IP地址,该脚本如何提醒我? 我想区分具有1个IP地址和多个1个IP地址的计算机。 (我正在尝试查找具有多个NIC的计算机)
我在 ForEach($ proc中的$ p){
#Get-ADComputer -Filter * -Property * | Select-Object Name | Out-File C:\Users\USERNAME\Desktop\change_dns\computers.txt
$computers = gc "C:\Users\USERNAME\Desktop\change_dns\computers.txt"
ForEach ($comp in $computers) {
if (Test-Connection -ComputerName $comp -BufferSize 16 -Count 1 -EA 0 -Quiet) {
$proc = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName $comp | Format-Table -Property IPAddress
ForEach ($p in $proc) {
#if $p contains more than one IPAddress, write-host or notify that the computer has more than one IP
#else if $p contains only 1 IPAddress, output that the computer only has one IP
}
}
# else {
# "$comp is Offline."
# }
}