jpa wrote:
Mark will need to fix this.
Or here's a stab at the problem. Works in my testing. May need more error checking or I've assumed things that aren't true.
This uses WMI to get the routing table, finds the default route and the associated network adapter then grabs the primary ip address from that if it can or it looks in the registry for the ip address if it can't.
Attachment:
audit_windows.txt [351.36 KiB]
Downloaded 143 times
This doesn't find an ip address if the ipv4 gateway is blank. But the previous didn't either so it's no worse that way. The WMI routing stuff is IPV4 only so it also doesn't work with IPV6 only configs. Haven't tested how it breaks. Probably just doesn't get an ip address. I also threw this together quick so it could use some pretty-ifiying.