AD1,
Welcome to the forum. ![]()
When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thanks in advance
Guide to Posting Code - Redux <---- Click
![]()
( !! Sometimes the preformatted text button hides behind the settings gear symbol.
)
Your $ipRange will cause issues - you know that, right? ![]()
$ipRange = 1..3
$subnet = '192.168.2.'
$Result =
foreach ($i in $ipRange) {
$ip = '{0}{1}' -f $subnet, $i
[PSCustomObject]@{
IP = $ip
IsActive = Test-Connection -ComputerName $ip -Count 1 -Quiet
}
}
$Result
$Result |
Export-Csv -Path .\NetworkScan.csv -NoTypeInformation