airflow.providers.microsoft.psrp.hooks.psrp

Module Contents

Classes

PsrpHook

Hook for PowerShell Remoting Protocol execution.

Attributes

INFORMATIONAL_RECORD_LEVEL_MAP

OutputCallback

airflow.providers.microsoft.psrp.hooks.psrp.INFORMATIONAL_RECORD_LEVEL_MAP[source]
airflow.providers.microsoft.psrp.hooks.psrp.OutputCallback[source]
class airflow.providers.microsoft.psrp.hooks.psrp.PsrpHook(psrp_conn_id, logging_level=DEBUG, operation_timeout=None, runspace_options=None, wsman_options=None, on_output_callback=None, exchange_keys=True, host=None)[source]

Bases: airflow.hooks.base.BaseHook

Hook for PowerShell Remoting Protocol execution.

When used as a context manager, the runspace pool is reused between shell sessions.

Parameters
  • psrp_conn_id (str) – Required. The name of the PSRP connection.

  • logging_level (int) – Logging level for message streams which are received during remote execution. The default is to include all messages in the task log.

  • operation_timeout (int | None) – Override the default WSMan timeout when polling the pipeline.

  • runspace_options (dict[str, Any] | None) – Optional dictionary which is passed when creating the runspace pool. See RunspacePool for a description of the available options.

  • wsman_options (dict[str, Any] | None) – Optional dictionary which is passed when creating the WSMan client. See WSMan for a description of the available options.

  • on_output_callback (OutputCallback | None) – Optional callback function to be called whenever an output response item is received during job status polling.

  • exchange_keys (bool) – If true (default), automatically initiate a session key exchange when the hook is used as a context manager.

  • host (pypsrp.host.PSHost | None) – Optional PowerShell host instance. If this is not set, the default implementation will be used.

You can provide an alternative configuration_name using either runspace_options or by setting this key as the extra fields of your connection.

conn_name_attr = 'psrp_conn_id'[source]
default_conn_name = 'psrp_default'[source]
conn_type = 'psrp'[source]
hook_name = 'PowerShell Remoting Protocol'[source]
__enter__()[source]
__exit__(exc_type, exc_value, traceback)[source]
get_conn()[source]

Return a runspace pool.

The returned object must be used as a context manager.

invoke()[source]

Yield a PowerShell object to which commands can be added.

Upon exit, the commands will be invoked.

invoke_cmdlet(name, use_local_scope=None, arguments=None, parameters=None, **kwargs)[source]

Invoke a PowerShell cmdlet and return session.

invoke_powershell(script)[source]

Invoke a PowerShell script and return session.

test_connection()[source]

Test PSRP Connection.

Was this entry helpful?