tag:blogger.com,1999:blog-15559937.post2568371553305434823..comments2024-02-19T07:53:28.238-05:00Comments on Plain Text Prose: how to retrieve your ip address with powershell...Marcus Ohhttp://www.blogger.com/profile/16669592705989568859noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-15559937.post-89092316848566929722022-04-24T17:35:45.752-05:002022-04-24T17:35:45.752-05:00This comment has been removed by a blog administrator.Ycorijusohttps://wakelet.com/wake/7HW4yCj4OD5HpxehuYHstnoreply@blogger.comtag:blogger.com,1999:blog-15559937.post-45612489479258552122012-10-27T13:31:41.755-05:002012-10-27T13:31:41.755-05:00I want to apologize in advanced…im new to this: Le...I want to apologize in advanced…im new to this: Lets say i wanted to pull the subnet out of the IP address using []. How do i set it to read the “.” as the separator instead of a Space? For ex if i do $nic.ipaddress[2] it will pull the 3rd set of numbers instead of the 3rd character?Matthttps://www.blogger.com/profile/07156947300801091058noreply@blogger.comtag:blogger.com,1999:blog-15559937.post-16567427379958408042012-09-07T12:04:23.877-05:002012-09-07T12:04:23.877-05:00Thanks for the blog posting. The below worked for...Thanks for the blog posting. The below worked for me on Windows 7. <br /><br />Getting the IPv4 address on the last entry in the DNS listing:<br /><br />(gwmi win32_networkadapterconfiguration | ? {$_.IPAddress -ne $null})[-1].ipaddress[0]<br /><br />...and the IPv6 version for the same DNS entry:<br /><br />(gwmi win32_networkadapterconfiguration | ? {$_.IPAddress -ne $null})[-1].ipaddress[1]Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-15559937.post-63759704772718954082012-08-16T06:36:28.380-05:002012-08-16T06:36:28.380-05:00created my own version based on the author's i...created my own version based on the author's initial writeup, input from marcus on using IPv4 in the search string and my own need to list multiple IPs assigned to the same machine: <br /><br />ipconfig | findstr .*IPv4.*[0-9].\. | % { $_.split()[-1] } Lucille Gallelihttps://www.blogger.com/profile/06803312289358729025noreply@blogger.comtag:blogger.com,1999:blog-15559937.post-80631339507046573752012-06-08T10:12:17.920-05:002012-06-08T10:12:17.920-05:00for what matter, you could exclude based on a rege...for what matter, you could exclude based on a regex match since ipv4 will never contain alpha characters... hmmm.Marcus Ohhttps://www.blogger.com/profile/16669592705989568859noreply@blogger.comtag:blogger.com,1999:blog-15559937.post-69142076421303217462012-06-08T09:53:33.731-05:002012-06-08T09:53:33.731-05:00Actually the [0] part at the end is sooo evil. If ...Actually the [0] part at the end is sooo evil. If your intent (albeit missled) is to get the ipv4 address only, add this to the pipeline instead<br />| ? {$_ -notlike "*:*}<br />which excludes anything that looks like a ipv6Conrad Braamhttps://www.blogger.com/profile/14516128061510018135noreply@blogger.comtag:blogger.com,1999:blog-15559937.post-76059548655183249742012-02-24T19:23:14.951-05:002012-02-24T19:23:14.951-05:00Windows 7 IPv4 only.
(Get-WmiObject -Class Win32_...Windows 7 IPv4 only.<br /><br />(Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE) | %{$_.ipaddress[0]}Buckyhttps://www.blogger.com/profile/01435569186006156334noreply@blogger.comtag:blogger.com,1999:blog-15559937.post-77421615322991365552011-10-13T00:18:12.937-05:002011-10-13T00:18:12.937-05:00This works for me for getting the IP address of th...This works for me for getting the IP address of the first active interface on Windows XP, unlike the line at the top of the post:<br /><br />(Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName .)[0].IPAddressAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-15559937.post-34483949332872438912011-06-01T15:55:38.204-05:002011-06-01T15:55:38.204-05:00For some reason this doesn't seem to work on W...For some reason this doesn't seem to work on Win 7 with multiple active adapters (such as having VMWare Workstation on your machine). At that point all that in returned is the next command line. If I strip the .ipaddress off the end I can see information from each adapter.<br /><br />Also - if I do this command on a machine with a single adapter I get both the ipv4 and the ipv6 address - what if I need to reference just the ipv4 address?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-15559937.post-26520193196202302322011-02-20T23:38:06.651-05:002011-02-20T23:38:06.651-05:00Thank you very much for posting; I needed just thi...Thank you very much for posting; I needed just this Powershell command for a college assignment!Dark-Starnoreply@blogger.comtag:blogger.com,1999:blog-15559937.post-64272869420938007622008-09-04T15:32:00.000-05:002008-09-04T15:32:00.000-05:00oh, one more thing... here is the equivalent in fo...oh, one more thing... here is the equivalent in for loop. i removed the complexity of passing through two for loops and just used token placement to find the exact location:<BR/><BR/>for /f "tokens=13,14" %a in ('ipconfig ^| findstr .*IPv4.*[0-9].\.') do @echo %bMarcus Ohhttps://www.blogger.com/profile/16669592705989568859noreply@blogger.comtag:blogger.com,1999:blog-15559937.post-61891537617137962052008-09-04T14:23:00.000-05:002008-09-04T14:23:00.000-05:00hey man, give this a try instead... i did this on ...hey man, give this a try instead... i did this on vista, but i don't have ipv6 enabled so i didn't run into the same issues as you describe. at any rate, i modified the regex statement which brings back a value without using an array so the [0] wasn't necessary anymore. here it is: <BR/><BR/>(ipconfig | findstr .*IPv4.*[0-9].\.).Split()[-1]Marcus Ohhttps://www.blogger.com/profile/16669592705989568859noreply@blogger.comtag:blogger.com,1999:blog-15559937.post-22967642354057107132008-09-04T13:43:00.000-05:002008-09-04T13:43:00.000-05:00This works great for XP, but breaks down when you ...This works great for XP, but breaks down when you add Vista clients as they have IPv6 enabled. We end up with two lines, 1 the first two bytes of the v6 address (delimited by :) then the v4 address. I can't seem to tweak it to only display the v4 address for both XP & Vista.Davehttps://www.blogger.com/profile/03999898911312010873noreply@blogger.com