Module Contents



PowerShell Remoting Protocol operator.


class*, psrp_conn_id, command=None, powershell=None, cmdlet=None, parameters=None, logging_level=DEBUG, runspace_options=None, wsman_options=None, psrp_session_init=None, **kwargs)[source]

Bases: airflow.models.BaseOperator

PowerShell Remoting Protocol operator.

Use one of the 'command', 'cmdlet', or 'powershell' arguments.

The 'securestring' template filter can be used to tag a value for serialization into a System.Security.SecureString (applicable only for DAGs which have render_template_as_native_obj=True).

When using the cmdlet or powershell arguments and when do_xcom_push is enabled, the command output is converted to JSON by PowerShell using the ConvertTo-Json cmdlet such that the operator return value is serializable to an XCom value.

  • psrp_conn_id (str) -- connection id

  • command (Optional[str]) -- command to execute on remote host. (templated)

  • powershell (Optional[str]) -- powershell to execute on remote host. (templated)

  • cmdlet (Optional[str]) -- cmdlet to execute on remote host (templated). Also used as the default value for task_id.

  • parameters (Optional[Dict[str, str]]) -- When using the cmdlet or powershell arguments, use this parameter to provide parameters (templated). Note that a parameter with a value of None becomes an argument (i.e., switch).

  • 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.

  • 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.

  • psrp_session_init (Optional[pypsrp.powershell.Command]) -- Optional command which will be added to the pipeline when a new PowerShell session has been established, prior to invoking the action specified using the cmdlet, command, or powershell parameters.

template_fields :Sequence[str] = ['cmdlet', 'command', 'parameters', 'powershell'][source]
ui_color = #c2e2ff[source]
execute(self, context)[source]

This is the main method to derive when creating an operator. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.


Fetch a Jinja template environment from the DAG or instantiate empty environment if no DAG.

Was this entry helpful?