Find a list of all IP addresses assigned to the local system
Hello everyone! The Brain Teaser series continues.
First, we would like to announce the winner of the previous brain teaser. We got a few answers in which many of them have a command length of 8. The shortest answer — ($x=ps), with 7 characters — was given by Mike F Robbins. So, he is the winner! In his solution, the assignment is placed inside the parenthesis so that the results of “ps” (alias to Get-Process) are stored in the variable $x as well as displayed on the console.
Congratulations Mike, you get an eBook version of Learn Windows PowerShell 3 in a Month of Lunches, Second Edition written by Don Jones and Jeffery Hicks.
Here is the new brain teaser!
Your new task is to get a list of IP addresses (IPv4 and IPv6, if present) of the local machine. Sounds easy? Well, here are some of the constraints to make it interesting:
- You cannot use WMI
- You cannot use IPCONFIG
- You cannot reference $env:ComputerName or localhost as the computer name
- Your command should return an IP address object!
- You cannot use Windows 8 networking cmdlets or similar for other OS
Please use the comment box at the bottom of this page to submit your solutions by Friday. The winner will be announced on the next Monday.
Don’t have a solution of your own or has it already been posted by others? You can still participate and add your voice by voting on the existing comment by using the up/down voting arrows.
This time, the prize is again the eBook version of Microsoft Windows PowerShell 3.0 First Look written by Adam Driscoll. We would like to thank our sponsor Packt, one of the most prolific and fast-growing tech book publishers in the world, for providing such a cool prize.
Good luck!Share on: