【问题标题】:Invoke-WebRequest not working in Azure AutomationInvoke-WebRequest 在 Azure 自动化中不起作用
【发布时间】:2015-06-12 18:10:35
【问题描述】:

Invoke-WebRequest 在 Azure 中不起作用。 我已经在 Powershell ISE 中测试了相同的代码,它可以工作。

这是错误:

4/8/2015 9:24:14 AM, Error: Microsoft.PowerShell.Utility\Write-Error : aa00-csmo-t2 - Could not download https://nage1.blob.core.w
indows.net/application/applicationcertificates.7z?sv=2014-02-14&sr=c&sig=ke1lxWQM%3D&se=2016-04-07T06%3A04%3A49Z&sp=r - 
At Install-Certificates:168 char:168
+ 
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : 
Microsoft.PowerShell.Commands.WriteErrorException,Microsoft.PowerShell.Commands.WriteErrorCommand

这是我在 Powershell ISE 中使用的代码:

workflow test
{
    $ApplicationCertsBlobUrl = 'https://nage1.blob.core.w
indows.net/application/applicationcertificates.7z?sv=2014-02-14&sr=c&sig=ke1lxWQM%3D&se=2016-04-07T06%3A04%3A49Z&sp=r'

    $applicationCertsZipFileSource = 'C:\Temp\test.7z'

    Invoke-WebRequest $ApplicationCertsBlobUrl -OutFile $applicationCertsZipFileSource
}

我也试过了:

InlineScript
            {
                $client = New-Object System.Net.WebClient
                $client.DownloadFile($using:ApplicationCertsBlobUrl, $using:applicationCertsZipFileSource)
            }

但是我得到了这个异常:

4/8/2015 9:40:14 AM, Error: Exception calling "DownloadFile" with "2" argument(s): "An exception occurred during a WebClient request."
At Install-Certificates:164 char:164
+ 
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

【问题讨论】:

    标签: powershell azure azure-automation powershell-workflow


    【解决方案1】:

    我必须将Invoke-WebRequest 包裹在InlineScript 中。

    【讨论】:

      猜你喜欢
      • 2018-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-15
      • 1970-01-01
      • 2020-08-29
      • 2019-10-08
      相关资源
      最近更新 更多