Ah heck, you can do that in one (long) line of PowerShell, even with spaces 
added for readability. ☺ ☺

( ( [text.encoding]::ASCII.GetString( (new-object net.webclient).DownloadData( 
"http://whatismyip.org"; ) ) ) + ", " + (get-date).ToShortDateString() + ", " + 
(get-date).ToShortTimeString() ) >>file.txt

Regards,

Michael B. Smith
Consultant and Exchange MVP
http://TheEssentialExchange.com

From: Richard Stovall [mailto:[email protected]]
Sent: Friday, June 24, 2011 10:09 AM
To: NT System Admin Issues
Subject: Re: Get external IP from command line

Well, what to do with the information is a different question from what the OP 
asked.  I was just offering another method of accomplishing the task at hand.

When I used to use that script I was only interested in having an ongoing 
record of when my ip changed.  Nothing more than that.  I didn't even care what 
the ip was.  Now I can't remember why I wanted to know when it changed...
On Fri, Jun 24, 2011 at 9:31 AM, John Aldrich 
<[email protected]<mailto:[email protected]>> wrote:
Yes, but what do you *do* with that info? I'm in a similar situation where I 
access my machine at home. I'm on a dynamic IP as well, but I run an 
application to update my dynamic DNS entry based on similar information to 
whatismyip.com<http://whatismyip.com/>. Thus, I only have to wait about 15 or 
20 minutes after the IP changes to be able to access my machine at home again. 
:D

Sometimes I think my ISP (Windstream) detects a large amount of traffic on my 
machine and decides to change my IP. Too bad I've figured out a work-around. :D



From: Richard Stovall [mailto:[email protected]<mailto:[email protected]>]
Sent: Friday, June 24, 2011 9:18 AM
To: NT System Admin Issues
Subject: Re: Get external IP from command line

Here's a little Powershell script to accomplish the same thing and write the 
result out to a history file.  I've used this via a scheduled task on my home 
machine to track when my FIOS ip changes.

$url = "http://whatismyip.org/";
$wc = new-object system.net.webclient
$data = $wc.DownloadData($url)
$ip = [System.Text.Encoding]::ASCII.GetString($data)
$date = get-date
$writestr = $ip + "," + " " + $date.toshortdatestring() + "," + " " + 
$date.ToShortTimeString()
add-content C:\somepath\ip.txt $writestr
On Fri, Jun 24, 2011 at 3:23 AM, Gavin Wilby 
<[email protected]<mailto:[email protected]>> wrote:
Stolen from another website, but this seems to work OK:


Create a file named ip.vbs and copy the following into it:

Option Explicit
Dim http : Set http = CreateObject( "MSXML2.ServerXmlHttp" )
http.Open "GET", "http://whatismyip.org<http://whatismyip.org/>", False
http.Send
Wscript.Echo http.responseText   'or do whatever you want with it
Set http = Nothing

Execute using

C:\>cscript ip.vbs


On Fri, Jun 24, 2011 at 7:59 AM, Oliver Marshall
<[email protected]<mailto:[email protected]>> wrote:
>
> Hi chaps
>
>
>
> Does anyone know of a command line tool that can return the external IP of 
> the machine it’s run on? I need to run a script on some machines and need to 
> note the external IP.
>
> Olly
>
>
>
>
>
> Network Support
> Online Backups
> Server Management
>
> Tel: 0845 307 3443<tel:0845%20307%203443>
>
> Email: [email protected]<mailto:[email protected]>
>
> Web: http://www.g2support.com<http://www.g2support.com/>
>
> Twitter: g2support
>
> Newsletter: http://www.g2support.com/newsletter
>
> Mail: 2 Roundhill Road, Brighton, Sussex, BN2 3RF
>
>
>
> Have you said something nice about us to a friend or colleague ?
>
> Let us say thanks. Find out more at 
> www.g2support.com/referral<http://www.g2support.com/referral>
>
>
>
> G2 Support LLP is registered at Mill House, 103 Holmes Avenue, HOVE
>
> BN3 7LE. Our registered company number is OC316341.
>
> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~
> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~
>
> ---
> To manage subscriptions click here: 
> http://lyris.sunbelt-software.com/read/my_forums/
> or send an email to 
> [email protected]<mailto:[email protected]>
> with the body: unsubscribe ntsysadmin

--
Gavin Wilby,
Twitter: http://twitter.com/gavin_wilby
GSXR Blog: http://www.stoof.co.uk<http://www.stoof.co.uk/>

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin

Reply via email to