- 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)¶
Hook for PowerShell Remoting Protocol execution.
When used as a context manager, the runspace pool is reused between shell sessions.
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.
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 (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.
- __exit__(exc_type, exc_value, traceback)¶
Returns a runspace pool.
The returned object must be used as a context manager.
Context manager that yields a PowerShell object to which commands can be added. Upon exit, the commands will be invoked.
- invoke_cmdlet(name, use_local_scope=None, **parameters)¶
Invoke a PowerShell cmdlet and return session.
Invoke a PowerShell script and return session.