powershell script for installing package in AEM from Octopus



power shell script for installing package in AEM through Octopus


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"


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


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

Answers (0)