# How to use Knife winrm with Elevated Privileges

**URL:** <https://discourse.chef.io/t/how-to-use-knife-winrm-with-elevated-privileges/9467>\
**Category:** Chef Infra (archive)\
**Created:** [September 21, 2016, 5:28am UTC](https://discourse.chef.io/t/how-to-use-knife-winrm-with-elevated-privileges/9467 "2016-09-21T05:28:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![manishmehra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/manishmehra/32/1484_2.png) [@manishmehra](https://discourse.chef.io/u/manishmehra)\
**Post date:** [September 21, 2016, 5:28am UTC](https://discourse.chef.io/t/how-to-use-knife-winrm-with-elevated-privileges/9467/1 "2016-09-21T05:28:51Z")

</div>

Greetings Masters

I am logging in with user “manish”. When I run command prompt “run as administrator” and pass chef-client, my executions passes. But when I open command prompt normally, my chef-client fails. It is OK when I run it locally because I can run it as administrator. But I am trying to run it remotely from workstation using “knife winrm” and I fail. Could you please tell me if we have a switch in chef “knife winrm” which will run the command “chef-client” as administrator.

Regards  
Manish

---

<div class="post-metadata">

**Author:** ![Matt\_Wrock](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/matt_wrock/32/3394_2.png) [@Matt\_Wrock](https://discourse.chef.io/u/Matt_Wrock)\
**Post date:** [September 21, 2016, 2:47pm UTC](https://discourse.chef.io/t/how-to-use-knife-winrm-with-elevated-privileges/9467/2 "2016-09-21T14:47:31Z")

</div>

Establishing a winrm connection with an admin user should run with administrative privileges. However, there are several commands that are known not to work over a winrm connection. The latest version of knife-windows (1.6.0) and the one released in the up coming chef-dk (0.18.22) provides a new command line argument `--winrm-shell` to the `knife winrm` command. You can specify `elevated` to this argument and all `knife winrm` commands will be run via a scheduled task to get around this winrm limitation. Note that the commands used with the elevated shell must be powershell.

---

<div class="post-metadata">

**Author:** ![nclemons](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/nclemons/32/3374_2.png) [@nclemons](https://discourse.chef.io/u/nclemons)\
**Post date:** [September 21, 2016, 2:59pm UTC](https://discourse.chef.io/t/how-to-use-knife-winrm-with-elevated-privileges/9467/3 "2016-09-21T14:59:48Z")

</div>

You can pass –x Administrator if you need and know the password.

Nathan Clemons  
DevOps Engineer  
Moxie Cloud Services (MCS)

O +1.425.467.5075  
M +1.360.861.6291  
E [nclemons@gomoxie.com](mailto:nclemons@gomoxie.com)  
W [www.gomoxie.com](http://www.gomoxie.com)[http://www.gomoxie.com/](http://www.gomoxie.com/)

---

<div class="post-metadata">

**Author:** ![manishmehra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/manishmehra/32/1484_2.png) [@manishmehra](https://discourse.chef.io/u/manishmehra)\
**Post date:** [September 22, 2016, 6:40am UTC](https://discourse.chef.io/t/how-to-use-knife-winrm-with-elevated-privileges/9467/4 "2016-09-22T06:40:07Z")

</div>

I am lucky enough to get stuck with the issue just one day before new release. Your words are great relief. Thanks.

As I am writing, the latest version of chefDK is 0.17.17. And as you mentioned, we will see a new version (0.18.22) sometime today. I will wait for the new release.

Just to be prepared, Am I correct about following statement?

```
If I execute this command:
knife winrm --winrm-shell elevated NODENAME "chef-client -c c:/chef/client.rb" -m -x user-name -P "Super-secret-password"

This means that the chef-client command will be executed on my NODENAME with elevated privileges. 

```

Please correct me if I am wrong.
