【发布时间】:2015-11-11 15:52:39
【问题描述】:
我正在尝试将多个文件一个一个地输入Invoke-WebRequest,并根据它是否有效写入成功或失败。
Param(
[string]$path,
[string]$file,
[string]$spath
)
cls
$URI = "Link Can't be shown."
$path = "C:\Users\lfouche.ESSENCEHEALTH\Desktop\Monitoring Services and Sites\"
$spath = "C:\Users\lfouche.ESSENCEHEALTH\Desktop\txtFiles\"
$file = (Get-ChildItem 'C:\Users\lfouche.ESSENCEHEALTH\Desktop\Monitoring Services and Sites')
$inF = "$path" + "$file" + ".txt"
$otF = "$spath" + "$file"
foreach ($f in $file) {
wget $URI -Method post -ContentType "text/xml" -InFile $inF -OutFile $otF
}
if ($? -eq 'true') {
"Successful"
} else {
"Failure"
$LASTEXITCODE
}
【问题讨论】:
标签: powershell powershell-4.0 powershell-ise