Page History
Table of Contents |
---|
Download
The JS7 PowerShell Command Line Interface Module is available
from
GitHub at https://github.com/sos-berlin/js7-cli-powershellfrom PowerShell Gallery at https://www.powershellgallery.com/packages/JobScheduler/2.0.0JS7
Code Block language powershell title PowerShell Gallery Find-Module -Name JS7 Install-Module -Name JS7
- from GitHub at https://github.com/sos-berlin/js7-cli-powershell
- Download and extract the JS7
Description
- PowerShell Module
- to a user's module location, for example for Windows
C:\Users\<user-name>\Documents\WindowsPowerShell\Modules\
or/home/<user-name>/.local/share/powershell/Modules
for a Linux environment, see$env:PSModulePath
for predefined module locations. - or to a location that is available for all users, e.g.
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
- or to an arbitrary location that later on is specified when importing the module.
- to a user's module location, for example for Windows
- The name of the downloaded archive (.zip, .tar.gz) and the name of included top-level folder might differ according to releases.
- For a release 2.0.8 the archive name could be
js7-cli-powershell-v.2.0.8.zip
and the included top-level folder would bejs7-cli-powershell-v.2.0.8
. - Having extracted the archive rename the top-level folder to
JS7
. This is required asJS7
is the effective module name.
- For a release 2.0.8 the archive name could be
- PowerShell Module
Introduction
The JS7 PowerShell Module The JS7 JobScheduler Command Line Interface (CLI) can be used to control JS7 instances and workflow-related objects.
The CLI module supports Windows PowerShell FullCLR 5.1 and PowerShell CoreCLR 6.x and 7.x for Windows, Linux and MacOS environments. It can be used with JS7 releases 2.0x. The CLI module is used for the following areas of operation:
- provide bulk operations:
- select orders and workflows
- manage orders with operations to start, stop, suspend
- deploy workflows
- run orders and workflows
- add orders to workflows
- manage Agents
- add Agents to Controllers
- check Agent status
- retrieve Agent job execution reports
Getting Started
Prerequisites
Check Execution Policy
PS > Get-ExecutionPolicy
- Shows the current execution policy, see e.g. Microsoft Technet about_Execution_Policies
PS > Set-ExecutionPolicy RemoteSigned
- The recommended execution policy for the JS7 PowerShell Module.
- Modifying the execution policy might require administrative privileges
Check Module Location
- .
PS > Set-ExecutionPolicy bypass -Scope process
- The recommended execution policy for use with jobs in JS7 workflows.
- PowerShell provides a number of locations for modules, see $env:PSModulePath for predefined module locations.
- Download/unzip the JobScheduler CLI module
- either to a user's module location, e.g. for Windows
C:\Users\<user-name>\Documents\WindowsPowerShell\Modules\
or/home/<user-name>/.local/share/powershell/Modules
for a Linux environment - or to a location that is available for all users, e.g.
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
- or to an arbitrary location that later on is specified when importing the module.
- either to a user's module location, e.g. for Windows
- Directory names might differ according to PowerShell versions.
- The required JobScheduler CLI module folder name is JobScheduler. If you download the module it is wrapped in a folder that specifies the current branch, e.g. scheduler-cli-powershell-1.2.0. Manually create the JobScheduler folder in the module location and add the contents of the scheduler-cli-powershell-1.2.0 folder from the archive.
Import Module
PS > Import-Module JS7
- loads the module from a location that is available with the PowerShell module path,
- see
$env:PSModulePath
for predefined module locations.
PS > Import-Module C:\some_module_location\JS7
- loads the module from a specific location, absolute and relative paths can be used on all platforms.
Hint: You can add the command Import-Module JS7
to your PowerShell profile to have the module loaded on start of a PowerShell session, see PowerShell CLI 1.1 - Use Cases - Credentials Management
Use Web Service
As a first operation after importing the module it is required to execute the Connect-JSJS7 cmdlet.
PS > Connect-JS7 -Url <Url> -AskForCredentials
- specifies the URL for JOC Cockpit by which the JOC Cockpit JS7 - REST Web Service is API is available and asks interactively for credentials. The default JOC Cockpit account is
root
with the passwordroot
.
- specifies the URL for JOC Cockpit by which the JOC Cockpit JS7 - REST Web Service is API is available and asks interactively for credentials. The default JOC Cockpit account is
PS > Connect-JS7 <Url> <Credentials> <JobSchedulerId><ControllerId>
orPS > Connect-JS7 -Url <Url> -Credentials <Credentials> -Id <ControllerId>
-Url
: specifies the URL of JOC Cockpit which is the same URL that you use when opening the JOC Cockpit GUI in your browser, e.g.http://localhost:4446
. When omitting the protocol (HTTP/HTTPS) for the URL then HTTP is used.-Credentials
: specifies the credentials (, for example the user account and password ) that are used to connect to the Web ServiceJOC Cockpit.- A credential object can be created by keyboard input like this:
Set-JSCredentials JS7Credentials -AskForCredentials
- A credential object can be created like this:
$credentials = ( New-Object -typename System.Management.Automation.PSCredential -ArgumentList 'root', ( 'root' | ConvertTo-SecureString -AsPlainText -Force) )
- The example makes use of the default account
root
and passwordroot
. - A possible location for the above code is a user's PowerShell Profile that would be executed for a PowerShell session.
- Credentials can be forwarded with the
-Url
parameter like this:Connect-JS7 -Url http://root:root@localhost:4446
- Specifying It is considered insecure to specify account and password with a URL is considered insecure.the URL .
- Find more examples including use of HTTPS connections with SSL certificates from JS7 - How to connect to JOC Cockpit using the PowerShell Module.
- A credential object can be created by keyboard input like this:
-Id
: specifies the Controller ID that the Controller has been installed withis registered with JOC Cockpit. As JOC Cockpit can manage a number of Controller instances Controllers the-Id
parameter can be used to select the respective Controller.
- The JS7 PowerShell module allows to execute cmdlets for the specified JOC Cockpit, Controller and Agents independently from the server and operating system that the respective JS7 Controller component is operated for, i.e. you can use . For example, users can invoke PowerShell cmdlets on Windows to manage a JS7 Controller running on a Linux box and vice versa. As an exception to this rule you cannot start a remote JS7 Controller instance and you cannot start a remote JS7 Windows service, however, you can restart, terminate , and abort , suspend and resume any JS7 Controller instance on any platform.
Run Commands
The JS7 CLI PowerShell module provides a number of cmdlets, see PowerShell CLI 2.0 - Cmdlets. Return values of cmdlets generally correspond to the JOC Cockpit JS7 - REST Web Service API.
- The complete list of cmdlets is available with the command:
PS > Get-Command -Module JS7
- Cmdlets come with a full name that includes the term
JS7
:PS > Get-JS7StatusJS7ControllerStatus
The
termJS7
can be abbreviated toJS
:PS > Get-JSStatus
The term JS7
can further be omitted if the resulting alias does not conflict with existing cmdlets:PS > Get-StatusControllerStatus
- Should conflicts occur with existing cmdlets from other modules then no conflicting aliases will be created. This includes aliases for cmdlets from the PowerShell Core as e.g.
Get-Job, Start-Job, Stop-Job
.
It is recommended to use the formGet-JS7Job, Start-JS7Job
etc. - Help information for a given cmdlet is available with:
PS > Get-Help Get-JS7Status JS7ControllerStatus -detailed
PS > man Get-JS7ControllerStatus
- An alias for the above
Get-Help
command.
- An alias for the above
Examples
Find some typical use cases for the JobScheduler CLI PowerShell CLI 2.0 - Use Cases for the JS7 PowerShell Module.
PS > Get-JS7Status JS7ControllerStatus -Display
- shows the summary information for a JS7 Controller.
PS > (Get-JS7Workflow).count
- shows the number of workflows that are available.
PS > (Get-JS7AgentInstance).count
- shows the number of Agents that are available.
PS > $orders = (Get-JS7Order -Directory Folder /my_orders -Recursive | Suspend-JS7Order)
- retrieves orders from the my_orders directory folder and any sub-folders with orders found that will be suspended. The list of affected orders is returned.
PS > $orders | CancelStop-JS7Order
- cancels orders based on a list that has previously been retrieved.
Manage Log Output
JobScheduler Cmdlets JS7 cmdlets consider verbosity and debug settings.
PS > $VerbosePreference = "Continue"
- This will cause verbose output to be created from cmdlets.
PS > $VerbosePreference = "SilentlyContinue"
- The verbosity level is reset.
PS > $DebugPreference = "Continue"
- This will cause debug output to be created from cmdlets.
PS > $DebugPreference = "SilentlyContinue"
- The debug level is reset.
Change Management References
Jira | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
...
Further Resources
Display children header |
---|