pac*_*ace 6 powershell export 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/')
Run Code Online (Sandbox Code Playgroud)
我已经尝试了out-file和export-csv,但它写了一个空白文件.我确信这很简单......但是没有知识对我来说很难.
add-content cmdlet应该可以执行您想要的操作.
假设$webClient.DownloadString('http://myip.dnsomatic.com/')返回一个字符串,请尝试:
Add-Content -Path $filename -Value $webClient.DownloadString('http://myip.dnsomatic.com/')
Run Code Online (Sandbox Code Playgroud)
参考:http: //technet.microsoft.com/en-us/library/dd347594.aspx
您还可以使用DownloadFile方法:
$webClient.DownloadFile('http://myip.dnsomatic.com/', 'c:\ip.txt')
Run Code Online (Sandbox Code Playgroud)