This should work unless that relies on any shell ism’s which are not available in win_command. Otherwise you have 2 other options if you really need to run it under command prompt
`
name: run it under win_shell and specify it to run under the cmd shell
win_shell: gcloud auth activate-service-account --key-file=C:\Users\user\Desktop\foo.json
args:
executable: cmd.exe
name: run it under win_command by creating a new cmd shell and executing the command
win_command: cmd.exe /c gcloud auth activate-service-account --key-file=C:\Users\user\Desktop\foo.json
`
The last example is close to what you were trying to do but to run a command in cmd you must pass the /c argument telling it what command to actually run.
A WinRM command always runs with the highest privileges possible, so under and admin it should run as an admin. You can check it out by running ‘whoami /groups’ in win_command, the mandatory label at the bottom tells you what level of privileges you are running with.
- medium is a standard user without admin privileges
- high is with admin privileges
- system is running under a well know service account and is similar to high