# Failed to execute command on return code 1

**URL:** https://discourse.chef.io/t/failed-to-execute-command-on-return-code-1/9185
**Category:** Chef Infra (archive)
**Created:** [August 16, 2016, 7:25am UTC](https://discourse.chef.io/t/failed-to-execute-command-on-return-code-1/9185 "2016-08-16T07:25:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![waseemahammed](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/waseemahammed/32/1708_2.png) [@waseemahammed](https://discourse.chef.io/u/waseemahammed)
#### Post date: [August 16, 2016, 7:25am UTC](https://discourse.chef.io/t/failed-to-execute-command-on-return-code-1/9185/1 "2016-08-16T07:25:47Z")

</div>

Hi,

I’ve been trying to bootstrap a windows node using WinRm, but I keep getting the following error.

root@ubuntu01:~/chef-repo/roles# knife bootstrap windows winrm 10.44.120.19 --winrm-user administrator --winrm-password ‘Redhat#10’ --node-name Win\_Node  
Creating new client for Win\_Node  
Creating new node for Win\_Node

Waiting for remote response before bootstrap.10.44.120.19 .  
10.44.120.19 Response received.  
Remote node responded after 0.0 minutes.  
10.44.120.19 AMD64  
Bootstrapping Chef on 10.44.120.19  
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 1  
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 2  
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 3  
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 4  
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 5  
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 6  
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 7  
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 8  
10.44.120.19 Checking for existing directory “C:\chef”…  
10.44.120.19 Existing directory not found, creating.

…  
…  
10.44.120.19 echo.8FHrSvOhpZfHm1MwIy1wZ9TeAReGrz2puvKxyj6KGB9E8KYJRXecfIoLgJTMIdpe  
10.44.120.19 echo.speqZLJiNFBeiyhIGETEobreBhIjdfwpS/xbWJBkwRLNWruUDExTbawvOG72h8e9  
10.44.120.19 echo.nyDnani0Hfha68JjAQ==  
10.44.120.19 echo.-----END CERTIFICATE-----  
10.44.120.19 ) 1\>C:\chef/trusted\_certs/wildcard\_opscode\_com.crt  
10.44.120.19 ‘chef-client’ is not recognized as an internal or external command,  
10.44.120.19 operable program or batch file.  
10.44.120.19  
10.44.120.19 C:\Users\Administrator\>(  
10.44.120.19 echo.-----BEGIN CERTIFICATE-----  
10.44.120.19 echo.MIIElDCCA3ygAwIBAgIQAf2j627KdciIQ4tyS8+8kTANBgkqhkiG9w0BAQsFADBh  
10.44.120.19 echo.MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3  
…  
…  
10.44.120.19 C:\Users\Administrator\>SET "PATH=C:\Program Files\Microsoft SQL Server\100\Tools\Binn;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;;C:\Program Files (x86)\Microsoft Azure Site Recovery\home\svsystems\bin;C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib;C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin;C:\thirdparty\rrdtool-1.2.15-win32-perl58\rrdtool\Release;C:\thirdparty\rrdtool-1.2.15-win32-perl58\rrdtool\bindings\perl-shared;C:\thirdparty\php5nts;C:\thirdparty\php5nts\ext;C:\windows;C:\strawberry\perl\bin;C:\strawberry\c\bin;C:\thirdparty\Cygwin\bin;C:\Program Files\Oracle\VirtualBox;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\Redist;C:\opscode\chef\bin;C:\ruby\bin;C:\opscode\chef\bin;C:\opscode\chef\embedded\bin"  
10.44.120.19  
10.44.120.19 C:\Users\Administrator\>chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json  
ERROR: Failed to execute command on 10.44.120.19 return code 1

Can somebody help me with this??

---

<div class="post-metadata">

### Author: ![waseemahammed](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/waseemahammed/32/1708_2.png) [@waseemahammed](https://discourse.chef.io/u/waseemahammed)
#### Post date: [August 16, 2016, 7:34am UTC](https://discourse.chef.io/t/failed-to-execute-command-on-return-code-1/9185/2 "2016-08-16T07:34:06Z")

</div>

Tried again, ended with this-

10.44.120.19 C:\Users\Administrator\>SET  
10.44.120.19 "PATH=C:\Program Files\Microsoft SQL Server\100\Tools\Binn;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;;C:\Program Files (x86)\Microsoft Azure Site Recovery\home\svsystems\bin;C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib;C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin;C:\thirdparty\rrdtool-1.2.15-win32-perl58\rrdtool\Release;C:\thirdparty\rrdtool-1.2.15-win32-perl58\rrdtool\bindings\perl-shared;C:\thirdparty\php5nts;C:\thirdparty\php5nts\ext;C:\windows;C:\strawberry\perl\bin;C:\strawberry\c\bin;C:\thirdparty\Cygwin\bin;C:\Program Files\Oracle\VirtualBox;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\Redist;C:\opscode\chef\bin;C:\ruby\bin;C:\opscode\chef\bin;C:\opscode\chef\embedded\bin"  
10.44.120.19  
10.44.120.19  
10.44.120.19 C:\Users\Administrator\>chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json  
10.44.120.19 [2016-08-15T22:28:39-07:00] INFO: \*\*\* Chef 12.13.37 \*\*\*  
10.44.120.19 [2016-08-15T22:28:39-07:00] INFO: Platform: x64-mingw32  
10.44.120.19 [2016-08-15T22:28:39-07:00] INFO: Chef-client pid: 3736  
10.44.120.19 [2016-08-15T22:29:08-07:00] INFO: HTTP Request Returned 401 Unauthorized: error  
10.44.120.19  
10.44.120.19 ================================================================================  
10.44.120.19 Chef encountered an error attempting to load the node data for "Win\_Node"  
10.44.120.19 ================================================================================  
10.44.120.19  
10.44.120.19 Authentication Error:  
10.44.120.19 ---------------------  
10.44.120.19 Failed to authenticate to the chef server (http 401).  
10.44.120.19 The request failed because your clock has drifted by more than 15 minutes.  
10.44.120.19 Syncing your clock to an NTP Time source should resolve the issue.  
10.44.120.19  
10.44.120.19 Platform:  
10.44.120.19 ---------  
10.44.120.19 x64-mingw32  
10.44.120.19  
10.44.120.19 [2016-08-15T22:29:08-07:00] ERROR: Running exception handlers  
10.44.120.19 [2016-08-15T22:29:08-07:00] ERROR: Exception handlers complete  
10.44.120.19 [2016-08-15T22:29:08-07:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out  
10.44.120.19 [2016-08-15T22:29:08-07:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report  
10.44.120.19 [2016-08-15T22:29:08-07:00] FATAL: Net::HTTPServerException: 401 "Unauthorized"  
ERROR: Failed to execute command on 10.44.120.19 return code 1

---

<div class="post-metadata">

### Author: ![chris\_sullivan](https://avatars.discourse-cdn.com/v4/letter/c/bc79bd/32.png) [@chris\_sullivan](https://discourse.chef.io/u/chris_sullivan)
#### Post date: [August 16, 2016, 7:47am UTC](https://discourse.chef.io/t/failed-to-execute-command-on-return-code-1/9185/3 "2016-08-16T07:47:13Z")

</div>

Hello @waseemahammed

The second error you have is because of a time difference between your node and the Chef server.

```auto
10.44.120.19 Authentication Error:
10.44.120.19 ---------------------
10.44.120.19 Failed to authenticate to the chef server (http 401).
10.44.120.19 The request failed because your clock has drifted by more than 15 minutes.
10.44.120.19 Syncing your clock to an NTP Time source should resolve the issue.
10.44.120.19 

```

I’ve found a lot of the Chef errors are quite well documented

[https://docs.chef.io/errors.html#synchronize-the-clock-on-your-host](https://docs.chef.io/errors.html#synchronize-the-clock-on-your-host)

With the first error can you run the

```auto
chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json 

```

With debug on ( -l debug on the command line)

---

<div class="post-metadata">

### Author: ![waseemahammed](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/waseemahammed/32/1708_2.png) [@waseemahammed](https://discourse.chef.io/u/waseemahammed)
#### Post date: [August 16, 2016, 7:57am UTC](https://discourse.chef.io/t/failed-to-execute-command-on-return-code-1/9185/4 "2016-08-16T07:57:42Z")

</div>

> [@chris\_sullivan](#):
>
> chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json

Tried both and worked 🙂 Thank you @chris_sullivan 😄
