I am developing a Powershell app for my company to allow our Help Desk to get some details quickly to copy into a ticket. I have the following commands which appears to work and get the desired result
(Get-NetIPaddress -InterfaceAlias Ethernet*).IPv4Address
(Get-NetIPaddress -InterfaceAlias Wireless*).IPv4Address
My issue is if I disconnect the ethernet cable or from the wireless and then re-run the command, I still get the IP addresses I got when I ran the command while connected and cannot find a way to clear this or to read this live.
I would prefer to keep the Wireless and wired IP Address separate, but is anyone able to suggest a way in which I can keep this to the current IP address (or show nothing if disconnected) and only give me the IP address, no other text.
Thank you in advance of any help you may be able to provide