Versions Compared

Key

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

...

SYNOPSIS

Connects to the JS7 REST Web Service available from JOC Cockpit Web Service.

SYNTAX

Connect-JS7 [-Url] <Uri> [[-Credentials] <PSCredential>] [[-Id] <String>] [-AskForCredentials] [-UseDefaultCredentials] [[-ProxyUrl] <Uri>] [[-ProxyCredentials] <PSCredential>] [-ProxyUseDefaultCredentials] [[-Base] <String>] [[-Timeout] <Int32>] [[-SSLProtocol] <String>] [[-Certificate] <X509Certificate2>] [[-CertificateThumbprint] <String>] [[-KeyStorePath] <String>] [[-KeyStoreCredentials] <PSCredential>] [[-RootCertificatePath] <String>] [[-RootCertificateCredentials] <PSCredential>] [-SkipCertificateCheck] [-ControllerDetails] [<CommonParameters>]

DESCRIPTION

A connection to the JOC Cockpit JS7 REST Web Service is established including support for credentials and use of a proxy.

The cmdlet authenticates a user account and returns an access token in case of successful authentication
that is used for subsequent requests to the Web Service.

The following REST Web Service API resources are used:

* /authentication/login
* /controller/switch
* /controller/ids
* /controllers

Caveat:
* This cmdlet calls the Invoke-WebRequest cmdlet that may throw an error 'The response content cannot be parsed because the Internet Explorer engine
is not available, or Internet Explorers first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again.'

* This problem is limited to Windows. The reason for this error is a weird PowerShell dependency on IE assemblies.
* If Internet Explorer is not configured then it prompts the user for configuration when being launched.

* To disable IE's first launch configuration window you can modify the Windows registry
** by running a PowerShell script: Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main' -Name 'DisableFirstRunCustomize' -Value 2
** by using the 'regedit' utility and navigating in the HKLM hive to the above key 'DisableFirstRunCustomize' and assigning the value '2'.
** this operation requires administrative permissions.

...

-Credentials <PSCredential>
Specifies a credentials object that is used to authenticate the account with the JS7 Web Service.

Credentials can be specified in a script:

* PS C:\> $credential = ( New-Object -typename System.Management.Automation.PSCredential -ArgumentList 'root', ( 'root' | ConvertTo-SecureString -AsPlainText -Force) )

Credentials sets can be managed with Windows built-in tools such as:

* PS C:\> cmdkey /generic:JS7 Web Service /user:root /pass:secret
* The Windows Credential Manager that is available Windows Control Panel.

A previously created credentials set can be retrieved by use of the cmdlet:

* PS C:\> $credentials = Get-JS7SystemCredentials -TargetName "JS7 Web Service"

The credentials object can be assigned the -Credentials parameter.

...

-Id <String>
Specifies the ID of a JS7 Controller that is registered with JOC Cockpit.
If no ID is specified then the first JS7 Controller registered with JOC Cockpit will be used.
The first Controller is identified from the Controller selected with a previous session of the REST API.

Required?false
Position?3
Default value
Accept pipeline input?true (ByValue, ByPropertyName)
Accept wildcard characters?false

...

-Base <String>
The Base is used as a prefix to the Path path for web service URLs and is configured with the web server
that hosts the JS7 Web Service.

This value is fixed and should not be modified for most use cases.

Default: /joc/api

...

-Timeout <Int32>
Specifies the timeout in seconds to wait for the JS7 REST Web Service response.

...

-Certificate <X509Certificate2>
This parameter can be used for client authentication if JOC Cockpit is configured for mutual authentication with HTTPS (SSL).
If JOC Cockpit is configured to accept onesingle-factor authentication then the certificate specified with this parameter replaces
the password for login. If JOC Cockpit requires two-factor authentication then a certificate is required
in addition to specifying a password for login.
Consider
Note that this parameter expects a certificate with the data type [System.Security.Cryptography.X509Certificates.X509Certificate2].
This parameter can be used for Windows only. For other operating systems use the -KeyStorePath parameter.

Use of this parameter requires that the certificate object includes the private key and the certificate chain, i.e. the certificate
and any intermediate/root certificates Intermediate or Root CA Certificates required for validation of the certificate.

This parameter cannot be used with the -CertificateThumbprint parameter or -KeyStorePath parameter.

...

-CertificateThumbprint <String>
This parameter can be used for client authentication if JOC Cockpit is configured for mutual authentication with HTTPS (SSL).
If JOC Cockpit is configured to accept onesingle-factor authentication then the certificate identified with this parameter replaces
the password for login. If JOC Cockpit requires two-factor authentication then a certificate is required
in addition to specifying a password for login.

This parameter can be used for Windows only. For other operating sysems use the -KeyStorePath parameter.

Use of this parameter requires a certificate store to be in place that holds the private key and certificate chain, i.e. the same certificate
and any intermediate/root certificates Intermediate or Root CA Certificates required for validation of the certificate. Consider Note that this parameter a reference
to a certificate entry in your Windows certificate store that includes the private key and certificate chain.

This parameter cannot be used with the -Certificate parameter or -KeyStorePath parameter.

...

-KeyStorePath <String>
This parameter can be used for client authentication if the JOC Cockpit is configured for mutual authentication with HTTPS (SSL).
If the JOC Cockpit is configured to accept onesingle-factor authentication then the certificate from the keystore specified with this parameter replaces
the password for login. If the JOC Cockpit requires two-factor authentication then a certificate is required
in addition to specifying a password for login.

This parameter expects the path to a keystore file, preferably a PKCS12 keystore, that holds the private key and certificate chain, i.e. the certificate
and any intermediate/root certificates Intermediate or Root CA Certificates required for validation of the certificate. Certificates of type X509 are supported.

The cmdlet adds the private key, certificate and any intermediate/root certificates from the keystore to the certificate store
used by the current account. This parameter can be used for Windows and Unix operating systems.

This parameter cannot be used with the -Certificate parameter or -CertificateThumbprint parameter.

...

-RootCertificatePath <String>
Specifies the location of a file that holds the root certificate that was used when signing the JOC Cockpit
SSL certificate.

* For Windows environments the root certificate Root CA Certificate by default is looked up in the Windows Certificate Store, however. However,
this parameter can be used to apply a root certificate Root CA Certificate from a location in the file system.
* For Linux environments a path is specified to the root certificate Root CA Certificate file, e.g. *.pem, *.crt file, or to a truststore, e.g. *.jks, *.p12 file.

...

-RootCertificateCredentials <PSCredential>
Specifies the credentials for access to a truststore that holds the root certificateRoot CA Certificate.

A credentials object can be created in a number of ways, e.g.:

$trustStoreCredentials = ( New-Object -typename System.Management.Automation.PSCredential -ArgumentList 'truststore', ( 'jobscheduler' | ConvertTo-SecureString -AsPlainText -Force) )

The first argument 'truststore' is arbitrary, the second argument 'jobscheduler' specifies the password to the truststore.

...

PS > Connect-JS7 -Url https://js7-joc-promaryprimary:4443 -AskForCredentials -RootCertificatePath /home/sos/root-ca.crt

Connects to the JS7 Web Service with a secure HTTPS connection at the indicated address and asks the user interactively for credentials. In order to verfy verify the JOC Cockpit server certificate the corresponding root certificate Root CA Certificate is specified that was used when signing the server certificate.

...

PS > $credentials = ( New-Object -typename System.Management.Automation.PSCredential -ArgumentList 'root', ( 'root' | ConvertTo-SecureString -AsPlainText -Force) )
Connect-JS7 -Url http://localhost:4446 -Credentials $credentials -Id jobscheduler

A variable $credential $credentials is created that holds the credentials for the default root account of JOC Cockpit. When calling the cmdlet the URL is specified, the Controller ID that was used during installationn installation and the credential credentials object.

-------------------------- EXAMPLE 4 --------------------------

...

Prior to use with PowerShell with some external command ("cmdkey") a credential credentials set is generated for the current user. The credentials are retrieved by use of the Get-JS7SystemCredentials cmdlet and are forwarded to the Connect-JS7 cmdlet.

...

This example assumes a secure HTTPS connection to JOC Cockpit with mutual authentication: * The -RootCertificatePath is specified that holds the root certificate that Root CA Certificate which was used when signing the JOC Cockpit SSL server certificate. * The -KeyStorePath is specified that hold holds the private key and certificate for mutual authentication with JOC Cockpit. * A $trustStoreCredentials variable $trustStoreCredentials is created that holds the password for access to the the truststore with the root certificateRoot CA Certificate. * A $keyStoreCredentials variable $keyStoreCredentials is created that holds the credentials for access to they keystore for mutual authentication.