Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepowershell
titleDefault PowerShell profile
linenumberstrue
$PSReadLineOptions = @{Colors=@{"Default"="Blue"; "Command"="Blue"; "Parameter"="Blue"; "Variable"="Blue"; "Number"="Blue"; "Member"="Blue"; "Operator"="Blue"}}
Set-PSReadlineOption -Colors $PSReadLineOptions.Colors

if ( Test-Path $env:JS7_AGENT_CONFIG_DIR/Microsoft.PowerShell_profile.ps1 -PathType Leaf -ErrorAction SilentlyContinue )
{
  .  $env:JS7_AGENT_CONFIG_DIR/Microsoft.PowerShell_profile.ps1
}

Running PowerShell Commands inside the Container

To try out a "plus" Agent container you can use the following sequence of commands:

Code Block
languagepowershell
titleExecute PowerShell cmdlets in a "plus" container
linenumberstrue
# fromFrom the Docker host openinvoke a PowerShell session within the Agent container
docker exec -ti js7-agent-primary pwsh

# Receive a PowerShell prompt like this
#   PowerShell 7.1.3
#   Copyright (c) Microsoft Corporation.
#   https://aka.ms/powershell
#   Type 'help' to get help.
#   PS />

# Load the JS7 PowerShell module
PS />Import-Module JS7

# Connect to the JOC Cockpit container specifying account ("root") and password ("root") with the JOC Cockpit URL like this:
PS />Connect-JS7 -Url http://root:root@js7-joc-primary:4446 -Id jobscheduler

# An alternative way is to create a credential object like this
#   PS />$credentials = ( New-Object -typename System.Management.Automation.PSCredential -ArgumentList "root", ( "root" | ConvertTo-SecureString -AsPlainText -Force) )
#   PS />Connect-JS7 -Url http://js7-joc-primary:4446 -Id jobscheduler -Credentials $credentials

# The recommended way is to login to the JOC Cockpit REST API by use of a certificate should JOC Cockpit be configured for HTTPS and certificate based authentication
#   PS />$credentials = ( New-Object -typename System.Management.Automation.PSCredential -ArgumentList "certs", ( "jobscheduler" | ConvertTo-SecureString -AsPlainText -Force) )
#   PS />Connect-JS7 -Url https://js7-joc-primary:4443 -id jobscheduler -KeyStorePath /var/sos-berlin.com/js7/agent/var_4445/config/private/https-keystore.p12 -KeyStoreCredentials $credentials -RootCertificatePath /var/sos-berlin.com/js7/agent/var_4445/config/private/https-truststore.p12 -RootCertificateCredentials $credentials

# Display Controller status
PS />Get-JS7ControllerStatus -display

# The command should return the following output:
#   ________________________________________________________________________
#   ....... Controller ID: jobscheduler
#   ............. version: 2.0.0-alpha.20210511
#   ................. URL: http://controller-2-0-primary:4446
#   ................ role: PRIMARY
#   ............... title: PRIMARY CONTROLLER
#   ....... running since: 04/30/2021 15:00:34
#   ...... security level: MEDIUM
#   ..... cluster coupled: True
#   .. cluster node state: active
#   .... component status: operational
#   ... connection status: established
#   ________________________________________________________________________

Running PowerShell Jobs

To execute PowerShell code from a job running inside a "plus" Agent container you can use the following sequence of commands:

Code Block
languagepowershell
titleExecute PowerShell cmdlets in a "plus" container
linenumberstrue
pwsh -NoLogo -NonInteractive -Command '& {
    Import-Module JS7
    Connect-JS7 -Url http://root:root@js7-joc-primary:4446 -Id jobscheduler

    Get-JS7ControllerStatus -display
}'

Further Resources

Configure the Agent

...