...
- The script is executable from the command line
- for Windows by use of the
pwsh.exe
PowerShell interpreter like this:pwsh.exe -f ./Start-JobSchedulerOrder.ps1 -JobChain /bjb/shell_chain -Order sample_order
- for Linux and MacOS by directly calling the script and by implictly using the shebang (
#!/usr/bin/pwsh
) to reference the interpreter like this:./Start-JobSchedulerOrder.ps1 -JobChain /bjb/shell_chain -Order sample_order
- for Windows by use of the
- Use of JobScheduler PowerShelll CLI
Code
Code Block language powershell title AddStart-JobSchedulerOrder.ps1 collapse true #!/usr/bin/pwsh param ( [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelinebyPropertyName=$True)] [string] $JobChain, [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelinebyPropertyName=$True)] [string] $Order, [Parameter(Mandatory=$False,ValueFromPipeline=$False,ValueFromPipelinebyPropertyName=$True)] [String] $Parameters = '', [Parameter(Mandatory=$False,ValueFromPipeline=$False,ValueFromPipelinebyPropertyName=$True)] [string] $At = 'now', [Parameter(Mandatory=$False,ValueFromPipeline=$False,ValueFromPipelinebyPropertyName=$True)] [string] $State, [Parameter(Mandatory=$False,ValueFromPipeline=$False,ValueFromPipelinebyPropertyName=$True)] [string] $EndState, [Parameter(Mandatory=$False,ValueFromPipeline=$False,ValueFromPipelinebyPropertyName=$True)] [string] $Id = $global:JobSchedulerId, [Parameter(Mandatory=$False,ValueFromPipeline=$False,ValueFromPipelinebyPropertyName=$True)] [Uri] $Url = $global:JobSchedulerUrl, [Parameter(Mandatory=$False,ValueFromPipeline=$False,ValueFromPipelinebyPropertyName=$True)] [PSCredential] $Credentials = $global:JobSchedulerCredentials, [Parameter(Mandatory=$False,ValueFromPipeline=$False,ValueFromPipelinebyPropertyName=$True)] [string] $Separator = ';' ) if ( !$Id ) { throw "missing value for parameter -Id" } if ( !$Url ) { throw "missing value for parameter -Url" } if ( !$Credentials -and !$Url.UserInfo ) { throw "missing value for parameter -Credentials" } Import-Module JobScheduler if ( $Url.UserInfo ) { $ws = Use-JobSchedulerWebService -Url $Url -Id $Id } else { $ws = Use-JobSchedulerWebService -Url $Url -Id $Id -Credentials $Credentials } try { $order = Start-JobSchedulerOrder -JobChain $JobChain -Order $Order -At $At -State $State -EndState $EndState -Parameters ( ConvertFrom-StringData -StringData $Parameters.Replace($Separator, "`n") ) } catch { throw $_.Exception } finally { $ws = Use-JobSchedulerWebService -Url $Url -Id $Id -Disconnect }
- Explanations
- Basically the script is about the following operations:
- Import the JobScheduler Module
- Connect to the JOC Cockpit REST Web Service
- Add Start an order to with the JobScheduler Master
- Disconnect from the JOC Cockpit REST Web Service
- Follow above instructions about getting help to see detailed information about parameters
- Basically the script is about the following operations:
...