azureautomation/runbooks

Import Azure Modules to Automation

sowens81 opened this issue · 0 comments

Need some help, this may not actually be a script issue.

the Following code errors when run in the script:

$ModuleContentUrl = (Invoke-WebRequest -Uri $ModuleContentUrl -MaximumRedirection 0 -UseBasicParsing -ErrorAction Ignore).Headers.Location

When it run's the parameter is set to the following:
$ModuleContentUrl = "https://www.powershellgallery.com/api/v2/package/Az.Automation/1.3.5"

And we get the following error:

Invoke-WebRequest : Object moved
Object moved to here.

At line:1 char:22

  • ... ntentUrl = (Invoke-WebRequest -Uri $ModuleContentUrl -MaximumRedirect ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  • CategoryInfo : InvalidOperation: (Method: GET, Reques\u2026PowerShell/6.2.3
    }:HttpRequestMessage) [Invoke-WebRequest], HttpResponseException
  • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Any guidance would be great.