Last active
July 4, 2023 13:47
-
-
Save ElakkuvanR/a8e99fd1f5477d8c4355e8b95a3efa6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create session and log to Sitecore | |
| [CmdletBinding(DefaultParameterSetName = "no-arguments")] | |
| Param ( | |
| [Parameter(Mandatory = $true, HelpMessage = "The remote CM URL")] | |
| [string]$remoteCMUrl, | |
| [Parameter(Mandatory = $true, HelpMessage = "User name under PSE Security Group")] | |
| [string]$username, | |
| [Parameter(Mandatory = $true, HelpMessage = "Password")] | |
| [string]$password, | |
| [Parameter(Mandatory = $true, HelpMessage = "Name of the package to be installed")] | |
| [string]$packageName | |
| ) | |
| Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force | |
| Import-Module -Name ./SPE | |
| try { | |
| $session = New-ScriptSession -ConnectionUri $remoteCMUrl -Username $username -Verbose -Password $password -Timeout 1800 | |
| Write-Host 'Started installing the content the package' $packageName | |
| $pseArgs = @{ | |
| "packageName" = $packageName; | |
| } | |
| $jobId = Invoke-RemoteScript -Session $session -ScriptBlock { | |
| Install-Package -Path ($using:pseArgs).packageName -InstallMode Merge -MergeMode Merge -Verbose | |
| } -AsJob -Verbose | |
| # Run the above Install Package as Job and poll it till completion | |
| Wait-RemoteScriptSession -Session $session -Id $jobId -Delay 5 -Verbose | |
| Write-Host 'Ended installing the content the package' | |
| } | |
| catch { | |
| Write-Host $_.Exception | |
| exit | |
| } finally { | |
| Stop-ScriptSession -Session $session | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment