
Step-02: Setup a parameterized build job, create a string parameter for remote Host


Step-03: Setup a string parameter for remote User


Step-04: Setup a String parameter for Remote User Password


Step-05: Create a Powershell script to run a cold backup on AEM
[code lang=powershell]
# stopping the job if it encounters an error
$ErrorActionPreference = ‘Stop’
# Credentials are stored in env and dynamic variables
$SecurePassword = $env:Password | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $env:User, $SecurePassword
# Invoke a command on the remote machine.
Invoke-Command -ComputerName $env:Computer -Credential $cred -ScriptBlock {
Stop-Service -Name AEM6A
cd C:\Users\SKYDEVOPS\Desktop\AEM\Author\crx-quickstart
$fName=(Get-Item -Path “.\”).Parent.BaseName
compress-archive -Path C:\Users\SKYDEVOPS\Desktop\AEM\Author\crx-quickstart -CompressionLevel optimal -DestinationPath “C:\Users\SKYDEVOPS\Desktop\backups\$(get-date -f yyyy-MM-dd-hhmmss)_$fName.zip”
Start-Service -Name AEM6A
}
[/code]
[code lang=powershell]
# stopping the job if it encounters an error
$ErrorActionPreference = ‘Stop’
# Credentials are stored in env and dynamic variables
$SecurePassword = $env:Password | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $env:User, $SecurePassword
# Invoke a command on the remote machine.
Invoke-Command -ComputerName $env:Computer -Credential $cred -ScriptBlock {
Stop-Service -Name AEM6A
cd C:\Users\SKYDEVOPS\Desktop\AEM\Author\crx-quickstart
$fName=(Get-Item -Path “.\”).Parent.BaseName
compress-archive -Path C:\Users\SKYDEVOPS\Desktop\AEM\Author\crx-quickstart -CompressionLevel optimal -DestinationPath “C:\Users\SKYDEVOPS\Desktop\backups\$(get-date -f yyyy-MM-dd-hhmmss)_$fName.zip”
Start-Service -Name AEM6A
}
[/code]
No comments:
Post a Comment
If you have any doubts or questions, please let us know.