获取$ webclient.downloadstring写入Powershell中的文本文件 [英] Get $webclient.downloadstring to write to text file in 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屋!