The psexec module is a module not a connection plugin so the inventory setup doesn't really affect how it actually runs. What happens when you specify a task with the psexec module is that the Python code is run on the host specified and it connects to the Windows host that is specified by the module options. If we use the first example in the psexec documetation
- name: run a cmd.exe command
psexec:
hostname: server
connection_username: username
connection_password: password
executable: cmd.exe
arguments: /c echo Hello World
We can see that the client side that runs the psexec module will connect to 'server' using the credentials 'username'/'password' and execute 'cmd.exe /c echo Hello World'. Where this code is run is dependent on what the current playbook host is configured like. In most cases people will probably run this module on the localhost (Ansible controller) and this can be done by specifying 'hosts: localhost' on the playbook or by using 'delegate_to: localhost' like below.
- name: run a cmd.exe command
psexec:
hostname: server
connection_username: username
connection_password: password
executable: cmd.exe
arguments: /c echo Hello World
delegate_to: localhost
Delegate to is useful if you are running a task targeting towards one host but you need to run this individual task on a different host. Hopefully this helps to explain it a bit more.
Thanks
Jordan