Versions Compared

Key

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

...

  • 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\
    sosap
    • <user-name>\Documents\WindowsPowerShell\Modules\ or /home/
    sosap
    • <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.
  • 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.

...

  • PS > Import-Module JobScheduler
    • 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\JobScheduler
    • loads the module from a specific location, absolute and relative paths for can be used on all platforms.

Hint: You can add the command Import-Module JobScheduler 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-JS cmdlet.

  • PS > Connect-JS -Url <Url> -AskForCredentials
    • specifies the URL for which the JOC Cockpit REST Web Service is available and asks interactively for credentials. The default account is root with the password root.
  • PS > Connect-JS <Url> <Credentials> <JobSchedulerId> or PS C:\ > Connect-JS -Url <Url> -Credentials <Credentials> -Id <JobSchedulerId>
    • specifies the URL of JOC Cockpit which is the same URL that you would 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.
    • specifies the credentials (user account and password) that are used to connect to the Web Service.
      • A credential object can be created by keyboard input like this:
        • Set-JSCredentials -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 password root.
        • 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-JS -Url http://root:root@localhost:4446
        • Specifying account and password with a URL is considered insecure.
    • specifies the JobScheduler ID that the Master has been installed with. As JOC Cockpit can manage a number of Master instances the -Id parameter can be used to select the respective Master.
    • allows to execute cmdlets for the specified Master independently from the server and operating system that the JobScheduler Master is operated for, i.e. you can use PowerShell cmdlets on Windows to manage a JobScheduler Master running on a Linux box and vice versa. As an exception to this rule you cannot start a remote JobScheduler Master and you cannot start a remote JobScheduler Windows service, however, you can restart, terminate, abort, suspend and suspend resume any JobScheduler Master instance on any platform.

Run Commands

The JobScheduler CLI provides a number of cmdlets, see PowerShell CLI - Cmdlets. Return values of cmdlets generally correspond to the JOC Cockpit REST Web Service.

  • The complete list of cmdlets is available with the command:
    • PS > Get-Command -Module JobScheduler
  • Cmdlets come with a full name that includes the term JobScheduler:
    • PS > Get-JobSchedulerStatus
  • The term JobScheduler can be abbreviated to JS:
    • PS > Get-JSStatus
  • The term JobScheduler can further be omitted if the resulting alias does not conflict with existing cmdlets:
    • PS > Get-Status
  • 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 abbreviated form Get-JSJob, Start-JSJob etc. Aliases can be forced by use of the cmdlet
  • Help information for a given cmdlet is available with:
    • PS > . Use-JobSchedulerAliasGet-Help Get-JSStatus -detailed

Examples

Find some typical use cases for the JobScheduler CLI.

...

  • PS > Use-JSMaster -InstallPath <InstallationPath>
    • specifies the full installation path, e.g. C:\Program Files\sos-berlin.com\jobscheduler\scheduler1.10, for a locally available JobScheduler Master.
  • PS > Use-JSMaster -InstallPath $env:SCHEDULER_HOME
    • You can use the environment variable SCHEDULER_HOME that points to the installation path.
    • The JobScheduler CLI module on import checks availability of this environment variable.
  • PS > Use-JSMaster -Url <Url> -Id <JobSchedulerID>
    • specify both URL and JobScheduler ID (recommended).
    • determines if the Master with the specified JobSchedulerID is locally available.
  • Hints

Find some use cases for JobScheduler Master management:

...