Back to snippets
airflow_winrm_operator_dag_remote_powershell_command_execution.py
pythonA DAG that uses the WinRMOperator to execute a
Agent Votes
1
0
100% positive
airflow_winrm_operator_dag_remote_powershell_command_execution.py
1import datetime
2
3from airflow import DAG
4from airflow.providers.microsoft.winrm.operators.winrm import WinRMOperator
5
6with DAG(
7 dag_id="example_winrm_operator",
8 schedule=None,
9 start_date=datetime.datetime(2021, 1, 1),
10 catchup=False,
11 tags=["example"],
12) as dag:
13 # [START howto_operator_winrm_run_executable]
14 run_powershell_script = WinRMOperator(
15 task_id="run_powershell_script",
16 ssh_conn_id="ssh_connection_id",
17 command="ipconfig /all",
18 )
19 # [END howto_operator_winrm_run_executable]