Azure自动化:调用URL [英] Azure Automation: Calling a URL
本文介绍了Azure自动化:调用URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Azure自动化的新手.我想每个工作日早上调用一个URL并获取其HTML.这是我到目前为止所写的.
I am new to Azure Automation. I want to call a URL and get its HTML once every weekday morning. This is what I have written so far.
workflow Wakeup-Url
{
Param
(
[parameter(Mandatory=$true)]
[String]
$Url
)
$day = (Get-Date).DayOfWeek
if ($day -eq 'Saturday' -or $day -eq 'Sunday'){
exit
}
$output = ""
InlineScript {"$Using:output = (New-Object System.Net.WebClient).DownloadString(`"$Using:Url`");"}
write-output $output
}
当我测试Runbook时,它没有在输出中提供HTML.相反,我在输出窗格中得到的是:
Its not giving me the HTML in the output when I test the runbook. Instead what I get in the output pane is:
=(New-Object System.Net.WebClient).DownloadString(" https://my.url.com/abc.html );
推荐答案
您的InlineScript当前仅输出包含脚本的字符串,因为您在整个表达式周围加上了引号:
Your InlineScript is currently just outputting a string containing your script, since you put quotes around the entire expression:
InlineScript {"$Using:output = (New-Object System.Net.WebClient).DownloadString(`"$Using:Url`");"}
这就是我想要的:
$output = InlineScript { (New-Object System.Net.WebClient).DownloadString("$Using:Url"); }
这篇关于Azure自动化:调用URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文