
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 Start/Stop AEM service on a Remote Server
[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 {
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 {
Start-Service -Name AEM6A
}
[/code]
No comments:
Post a Comment
If you have any doubts or questions, please let us know.