Search code examples
salt-project

How to run a cmd in Windows with Admin priviledges in Salt


I have a simple system that is managed by Saltstack. The minions are Windows Server 2016 machines. I would like to run some command with Admin privileges. How would I achieve that in the .sls for the minion?

run-my-cmd:
  cmd.run:
     - cwd: C:\temp\
     - bg: True
     - name: 'some command'

Solution

  • Execute the command using Runas

    C:\Users\abcxyz>Runas /profile /user:Administrator "your command"