win_psexec – Runs commands (remotely) as another (privileged) user¶
Synopsis¶
- Run commands (remotely) through the PsExec service.
- Run commands as another (domain) user (with elevated privileges).
Requirements¶
The below requirements are needed on the host that executes this module.
- Microsoft PsExec
Parameters¶
Notes¶
Note
- More information related to Microsoft PsExec is available from https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
See Also¶
See also
- psexec – Runs commands on a remote Windows host based on the PsExec model
- The official documentation on the psexec module.
- raw – Executes a low-down and dirty command
- The official documentation on the raw module.
- win_command – Executes a command on a remote Windows node
- The official documentation on the win_command module.
- win_shell – Execute shell commands on target hosts
- The official documentation on the win_shell module.
Examples¶
- name: Test the PsExec connection to the local system (target node) with your user
win_psexec:
command: whoami.exe
- name: Run regedit.exe locally (on target node) as SYSTEM and interactively
win_psexec:
command: regedit.exe
interactive: yes
system: yes
- name: Run the setup.exe installer on multiple servers using the Domain Administrator
win_psexec:
command: E:\setup.exe /i /IACCEPTEULA
hostnames:
- remote_server1
- remote_server2
username: DOMAIN\Administrator
password: some_password
priority: high
- name: Run PsExec from custom location C:\Program Files\sysinternals\
win_psexec:
command: netsh advfirewall set allprofiles state off
executable: C:\Program Files\sysinternals\psexec.exe
hostnames: [ remote_server ]
password: some_password
priority: low
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Status¶
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors¶
- Dag Wieers (@dagwieers)
Hint
If you notice any issues in this documentation, you can edit this document to improve it.