Get $webclient.downloadstring to write to text file in Powershell

Question:

I’m not a programmer/scripter. I just need to get the following script to write to a file:

I’ve tried out-file and export-csv but it write a blank file. I’m sure it’s something simple…but having no knowledge makes it difficult for me.

Answer:

The add-content cmdlet should do what you want.

Assuming $webClient.DownloadString('http://myip.dnsomatic.com/') returns a string, try:

Reference:
http://technet.microsoft.com/en-us/library/dd347594.aspx

Source:

Get $webclient.downloadstring to write to text file in Powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply