Hi
Just started to learn PowerShell, created my first practical script which pings a list of desktops and laptops and if they are reachable exports out the remaining c: drive free space into a .csv file.
All is well until I realised a lot of laptops are failing to return any data because they are not reachable using test-connection even though I know the laptops are plugged into the network.
This seems to be because there is more than one IP address registered in DNS for some laptops. The second IP is from the a recent VPN connection the user initiated when they were working from home which remains registered in DNS for 7 days. If I do a NSLOOKUP on the hostname I can see both IP addresses, the live LAN IP as well as the previous VPN IP. It seems when test-connection pings the machine it sometimes returns the VPN IP which times out resulting in a failed ping.
Question is, is there a way if test-connection fails to check for a secondary IP registered in DNS and then ping that giving me a reachable device and a more complete disk space report?
Many Thanks ![]()