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 (Optional[int]) -- Override the default WSMan timeout when polling the pipeline.

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

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

  • on_output_callback (Optional[OutputCallback]) -- 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 (Optional[pypsrp.host.PSHost]) -- 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.

__enter__(self)[source]
__exit__(self, exc_type, exc_value, traceback)[source]
get_conn(self)[source]

Returns a runspace pool.

The returned object must be used as a context manager.

invoke(self)[source]

Context manager that yields a PowerShell object to which commands can be added. Upon exit, the commands will be invoked.

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

Invoke a PowerShell cmdlet and return session.

invoke_powershell(self, script)[source]

Invoke a PowerShell script and return session.

Was this entry helpful?