class_docstr: 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
  <https://docs.microsoft.com/en-us/powershell/
  module/microsoft.powershell.utility/convertto-json>`__ cmdlet such
  that the operator return value is serializable to an XCom value.
  
  :param psrp_conn_id: connection id
  :param command: command to execute on remote host. (templated)
  :param powershell: powershell to execute on remote host. (templated)
  :param cmdlet:
      cmdlet to execute on remote host (templated). Also used as the default
      value for `task_id`.
  :param arguments:
      When using the `cmdlet` or `powershell` option, use `arguments` to
      provide arguments (templated).
  :param parameters:
      When using the `cmdlet` or `powershell` option, use `parameters` to
      provide parameters (templated). Note that a parameter with a value of `None`
      becomes an *argument* (i.e., switch).
  :param logging_level:
      Logging level for message streams which are received during remote execution.
      The default is to include all messages in the task log.
  :param runspace_options:
      optional dictionary which is passed when creating the runspace pool. See
      :py:class:`~pypsrp.powershell.RunspacePool` for a description of the
      available options.
  :param wsman_options:
      optional dictionary which is passed when creating the `WSMan` client. See
      :py:class:`~pypsrp.wsman.WSMan` for a description of the available options.
  :param psrp_session_init:
      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.
class_docstr_tok: ["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","<","https",":","\/\/docs.microsoft.com\/en-us\/powershell\/","module\/microsoft.powershell.utility\/convertto-json",">","`","__","cmdlet","such","that","the","operator","return","value","is","serializable","to","an","XCom","value",".",":","param","psrp_conn_id",":","connection","id",":","param","command",":","command","to","execute","on","remote","host",".","(","templated",")",":","param","powershell",":","powershell","to","execute","on","remote","host",".","(","templated",")",":","param","cmdlet",":","cmdlet","to","execute","on","remote","host","(","templated",")",".","Also","used","as","the","default","value","for","`","task_id","`",".",":","param","arguments",":","When","using","the","`","cmdlet","`","or","`","powershell","`","option",",","use","`","arguments","`","to","provide","arguments","(","templated",")",".",":","param","parameters",":","When","using","the","`","cmdlet","`","or","`","powershell","`","option",",","use","`","parameters","`","to","provide","parameters","(","templated",")",".","Note","that","a","parameter","with","a","value","of","`","None","`","becomes","an","*","argument","*","(","i.e.",",","switch",")",".",":","param","logging_level",":","Logging","level","for","message","streams","which","are","received","during","remote","execution",".","The","default","is","to","include","all","messages","in","the","task","log",".",":","param","runspace_options",":","optional","dictionary","which","is","passed","when","creating","the","runspace","pool",".","See",":","py",":","class",":","`","~pypsrp.powershell.RunspacePool","`","for","a","description","of","the","available","options",".",":","param","wsman_options",":","optional","dictionary","which","is","passed","when","creating","the","`","WSMan","`","client",".","See",":","py",":","class",":","`","~pypsrp.wsman.WSMan","`","for","a","description","of","the","available","options",".",":","param","psrp_session_init",":","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","."]
code: def execute(self, context: Context) -> list[Any] | None:
      with PsrpHook(
          self.conn_id,
          logging_level=self.logging_level,
          runspace_options=self.runspace_options,
          wsman_options=self.wsman_options,
          on_output_callback=self.log.info
          if not self.do_xcom_push
          else None,
      ) as hook, hook.invoke() as ps:
          if self.psrp_session_init is not None:
              ps.add_command(self.psrp_session_init)
          if self.command:
              ps.add_script(f"cmd.exe /c @'\n{self.command}\n'@")
          else:
              if self.cmdlet:
                  ps.add_cmdlet(self.cmdlet)
              else:
                  ps.add_script(self.powershell)
              for argument in self.arguments or ():
                  ps.add_argument(argument)
              if self.parameters:
                  ps.add_parameters(self.parameters)
              if self.do_xcom_push:
                  ps.add_cmdlet("ConvertTo-Json")
  
      if ps.had_errors:
          raise AirflowException("Process failed")
  
      rc = ps.runspace_pool.host.rc
      if rc:
          raise AirflowException(
              f"Process exited with non-zero status code: {rc}"
          )
  
      if not self.do_xcom_push:
          return None
  
      return [json.loads(output) for output in ps.output]
  
file_path: airflow/airflow/providers/microsoft/psrp/operators/psrp.py
imports: from __future__ import annotations
  from logging import DEBUG
  from typing import TYPE_CHECKING, Any, Sequence
  from jinja2.nativetypes import NativeEnvironment
  from pypsrp.serializer import TaggedValue
  from airflow.exceptions import AirflowException
  from airflow.models import BaseOperator
  from airflow.providers.microsoft.psrp.hooks.psrp import PsrpHook
  from airflow.settings import json
  from airflow.utils.helpers import exactly_one
label_desc: Use image node_id 2 for calling the PsrpOperator obj's underlying member method code with example usage: obj.execute(context) and returns: unknown, None