powershell script for installing package in AEM from Octopus

shaikz66682001

04-03-2019

power shell script for installing package in AEM through Octopus

HI,

I am wroking on automating the build using the octopus.

with the user of power shell script i have taken the package from nexus repository and uploaded in my local crxde.

but i am not able to install the package. i am facing below error when installing the pacakge. please advice what i am missing.

_______________________________

$url = "http://localhost:4502/crx/packmgr/service/.json/etc/packages/export/{2}?cmd=install"

#$pair = "$($user):$($pass)"

#$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))

#$basicAuthValue = "Basic $encodedCreds"

#$Headers = @{

#    Authorization = $basicAuthValue

#}

$JSON = @{

    "@type" = "login"

    "username" = 'admin'

    "password" = 'admin'

} | ConvertTo-Json

$response = Invoke-RestMethod -Uri $url -Method POST -Body $JSON -ContentType "application/json"

Write-Host $response

Write-Host "Done"

ERROR

Invoke-RestMethod : The remote server returned an error: (403) Forbidden.

At line:20 char:14

+ ... $response = Invoke-RestMethod -Uri $url -Method POST -Body $JSON -Con ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebE

   xception

    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Answers (0)