获取$ webclient.downloadstring写入Powershell中的文本文件 [英] Get $webclient.downloadstring to write to text file in Powershell

查看:742
本文介绍了获取$ webclient.downloadstring写入Powershell中的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是一个程序员/写作者。我只需要得到以下脚本写入一个文件:

  [CmdletBinding()] 
param()

#创建一个Web客户端对象
$ webClient = New-Object System.Net.WebClient


#返回公共IP地址
$ webClient.DownloadString('http://myip.dnsomatic.com/')

ve尝试out-file和export-csv但它写一个空白文件。我确定这是一个简单的事情,但没有任何知识使我很难。

解决方案

add-content cmdlet应该做你想要的。



假设$ webClient.DownloadString(' http://myip.dnsomatic.com/ ')返回字符串try :

  add-content -path< filename> -value $ webClient.DownloadString('http://myip.dnsomatic.com/')

参考:


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


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

[CmdletBinding()]
param ()

# Create a web client object
$webClient = New-Object System.Net.WebClient


# Returns the public IP address
$webClient.DownloadString('http://myip.dnsomatic.com/')

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.

解决方案

The add-content cmdlet should do what you want.

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

add-content -path <filename> -value$webClient.DownloadString('http://myip.dnsomatic.com/')

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

这篇关于获取$ webclient.downloadstring写入Powershell中的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆