# Bootstrapping Windows Nodes via RDP

**URL:** <https://discourse.chef.io/t/bootstrapping-windows-nodes-via-rdp/3502>\
**Category:** Chef Infra (archive)\
**Created:** [January 17, 2013, 9:11am UTC](https://discourse.chef.io/t/bootstrapping-windows-nodes-via-rdp/3502 "2013-01-17T09:11:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hippiehacker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/hippiehacker/32/1469_2.png) [@hippiehacker](https://discourse.chef.io/u/hippiehacker)\
**Post date:** [January 17, 2013, 9:11am UTC](https://discourse.chef.io/t/bootstrapping-windows-nodes-via-rdp/3502/1 "2013-01-17T09:11:04Z")

</div>

winrm is disabled by default for many windows installs, including cloud  
providers such as Azure.

I’m contemplating a way around this limitation by either finding a way to  
turn on winrm, or just executing commands via RDP instead.

I found an interesting from blog entry from 2008\*[1] that suggested using  
the rdesktop executable (on linux) to run commands/scripts.

rdesktop -r disk:local="/tmp/dir/" my.new.server -s “cmd.exe /K net  
use x: \\tsclient\local & x:\setupwinrm.bat & shutdown /t 0 /r”

However that obviously requires shelling out to run a binary on Linux that  
requires the presence of an X server.

I was wondering if anyone has any suggestions or has seen any ruby gems or  
libraries that we could use to make something like this cross-platform.

The ideal scenario would give us the ability to run commands via the RDP  
procotol from plain ruby (no X or Linux required).

Then we could do something like:

knife bootstrap windows rdp my.new.server

[1] [http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html](http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html)

---

<div class="post-metadata">

**Author:** ![Paul\_Morton\_BIA](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/paul_morton_bia/32/480_2.png) [@Paul\_Morton\_BIA](https://discourse.chef.io/u/Paul_Morton_BIA)\
**Post date:** [January 17, 2013, 11:38am UTC](https://discourse.chef.io/t/bootstrapping-windows-nodes-via-rdp/3502/2 "2013-01-17T11:38:56Z")

</div>

Chris - winexe ships as part of samba 4 and can run on linux or osx. It is synonymous with psexec on windows.

Personally, with all of the quirks of winrm and powershell 3 constantly dumping due to memory issues, I am wondering if winexe is just the way to go for all remote shell operations…

P

On Jan 17, 2013, at 1:11 AM, “Chris McClimans” \<[chef@hippiehacker.org](mailto:chef@hippiehacker.org)[mailto:chef@hippiehacker.org](mailto:chef@hippiehacker.org)\> wrote:

winrm is disabled by default for many windows installs, including cloud providers such as Azure.

I’m contemplating a way around this limitation by either finding a way to turn on winrm, or just executing commands via RDP instead.

I found an interesting from blog entry from 2008\*[1] that suggested using the rdesktop executable (on linux) to run commands/scripts.

rdesktop -r disk:local="/tmp/dir/" my.new.server -s “cmd.exe /K net use x: \\tsclient\local & x:\setupwinrm.bat & shutdown /t 0 /r”

However that obviously requires shelling out to run a binary on Linux that requires the presence of an X server.

I was wondering if anyone has any suggestions or has seen any ruby gems or libraries that we could use to make something like this cross-platform.

The ideal scenario would give us the ability to run commands via the RDP procotol from plain ruby (no X or Linux required).

Then we could do something like:

knife bootstrap windows rdp my.new.server

[1] [http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html](http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html)

---

<div class="post-metadata">

**Author:** ![hippiehacker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/hippiehacker/32/1469_2.png) [@hippiehacker](https://discourse.chef.io/u/hippiehacker)\
**Post date:** [January 17, 2013, 7:52pm UTC](https://discourse.chef.io/t/bootstrapping-windows-nodes-via-rdp/3502/3 "2013-01-17T19:52:22Z")

</div>

Seems like we could do knife bootstrap windows exec and use different  
backends.

PsExec on windows  
winexe on Linux and OSX

The requirement of a full samba4 install is something we should noodle  
around.

Are there static linked binaries for OSX and Linux?

On Thu, Jan 17, 2013 at 3:38 AM, Paul Morton - BIA  
[pmorton@biaprotect.com](mailto:pmorton@biaprotect.com)wrote:

> Chris - winexe ships as part of samba 4 and can run on linux or osx. It is  
> synonymous with psexec on windows.
> 
> Personally, with all of the quirks of winrm and powershell 3 constantly  
> dumping due to memory issues, I am wondering if winexe is just the way to  
> go for all remote shell operations...
> 
> P
> 
> On Jan 17, 2013, at 1:11 AM, "Chris McClimans" [chef@hippiehacker.org](mailto:chef@hippiehacker.org)  
> wrote:
> 
> winrm is disabled by default for many windows installs, including cloud  
> providers such as Azure.
> 
> I'm contemplating a way around this limitation by either finding a way to  
> turn on winrm, or just executing commands via RDP instead.
> 
> I found an interesting from blog entry from 2008\*[1] that suggested using  
> the rdesktop executable (on linux) to run commands/scripts.
> 
> rdesktop -r disk:local="/tmp/dir/" my.new.server -s "cmd.exe /K net use x: \\tsclient\local & x:\setupwinrm.bat & shutdown /t 0 /r"
> 
> However that obviously requires shelling out to run a binary on Linux that  
> requires the presence of an X server.
> 
> I was wondering if anyone has any suggestions or has seen any ruby gems or  
> libraries that we could use to make something like this cross-platform.
> 
> The ideal scenario would give us the ability to run commands via the RDP  
> procotol from plain ruby (no X or Linux required).
> 
> Then we could do something like:
> 
> knife bootstrap windows rdp my.new.server
> 
> [1]  
> [http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html](http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html)

---

<div class="post-metadata">

**Author:** ![hippiehacker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/hippiehacker/32/1469_2.png) [@hippiehacker](https://discourse.chef.io/u/hippiehacker)\
**Post date:** [January 17, 2013, 8:18pm UTC](https://discourse.chef.io/t/bootstrapping-windows-nodes-via-rdp/3502/4 "2013-01-17T20:18:36Z")

</div>

Paul,

[http://eol.ovh.org/winexe/](http://eol.ovh.org/winexe/) has direction for building winexe, but I'm not  
finding winexe as part of the samba4 in Ubuntu 12.04.

At what version did Samba4 start including winexe?

On Thu, Jan 17, 2013 at 11:52 AM, Chris McClimans [chef@hippiehacker.org](mailto:chef@hippiehacker.org)wrote:

> Seems like we could do knife bootstrap windows exec and use different  
> backends.
> 
> PsExec on windows  
> winexe on Linux and OSX
> 
> The requirement of a full samba4 install is something we should noodle  
> around.
> 
> Are there static linked binaries for OSX and Linux?
> 
> On Thu, Jan 17, 2013 at 3:38 AM, Paul Morton - BIA \<[pmorton@biaprotect.com](mailto:pmorton@biaprotect.com)
> 
> > wrote:
> 
> > Chris - winexe ships as part of samba 4 and can run on linux or osx. It  
> > is synonymous with psexec on windows.
> > 
> > Personally, with all of the quirks of winrm and powershell 3 constantly  
> > dumping due to memory issues, I am wondering if winexe is just the way to  
> > go for all remote shell operations...
> > 
> > P
> > 
> > On Jan 17, 2013, at 1:11 AM, "Chris McClimans" [chef@hippiehacker.org](mailto:chef@hippiehacker.org)  
> > wrote:
> > 
> > winrm is disabled by default for many windows installs, including cloud  
> > providers such as Azure.
> > 
> > I'm contemplating a way around this limitation by either finding a way to  
> > turn on winrm, or just executing commands via RDP instead.
> > 
> > I found an interesting from blog entry from 2008\*[1] that suggested using  
> > the rdesktop executable (on linux) to run commands/scripts.
> > 
> > rdesktop -r disk:local="/tmp/dir/" my.new.server -s "cmd.exe /K net use x: \\tsclient\local & x:\setupwinrm.bat & shutdown /t 0 /r"
> > 
> > However that obviously requires shelling out to run a binary on Linux  
> > that requires the presence of an X server.
> > 
> > I was wondering if anyone has any suggestions or has seen any ruby gems  
> > or libraries that we could use to make something like this cross-platform.
> > 
> > The ideal scenario would give us the ability to run commands via the RDP  
> > procotol from plain ruby (no X or Linux required).
> > 
> > Then we could do something like:
> > 
> > knife bootstrap windows rdp my.new.server
> > 
> > [1]  
> > [http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html](http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html)

---

<div class="post-metadata">

**Author:** ![hippiehacker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/hippiehacker/32/1469_2.png) [@hippiehacker](https://discourse.chef.io/u/hippiehacker)\
**Post date:** [January 17, 2013, 8:26pm UTC](https://discourse.chef.io/t/bootstrapping-windows-nodes-via-rdp/3502/5 "2013-01-17T20:26:54Z")

</div>

OpenSUSE builds statics for most Linux distros:

[https://build.opensuse.org/package/show?package=winexe&project=home%3Aahajda%3Awinexe](https://build.opensuse.org/package/show?package=winexe&project=home%3Aahajda%3Awinexe)

On Thu, Jan 17, 2013 at 12:18 PM, Chris McClimans [chef@hippiehacker.org](mailto:chef@hippiehacker.org)wrote:

> Paul,
> 
> [http://eol.ovh.org/winexe/](http://eol.ovh.org/winexe/) has direction for building winexe, but I'm not  
> finding winexe as part of the samba4 in Ubuntu 12.04.
> 
> At what version did Samba4 start including winexe?
> 
> On Thu, Jan 17, 2013 at 11:52 AM, Chris McClimans [chef@hippiehacker.org](mailto:chef@hippiehacker.org)wrote:
> 
> > Seems like we could do knife bootstrap windows exec and use different  
> > backends.
> > 
> > PsExec on windows  
> > winexe on Linux and OSX
> > 
> > The requirement of a full samba4 install is something we should noodle  
> > around.
> > 
> > Are there static linked binaries for OSX and Linux?
> > 
> > On Thu, Jan 17, 2013 at 3:38 AM, Paul Morton - BIA \<  
> > [pmorton@biaprotect.com](mailto:pmorton@biaprotect.com)\> wrote:
> > 
> > > Chris - winexe ships as part of samba 4 and can run on linux or osx. It  
> > > is synonymous with psexec on windows.
> > > 
> > > Personally, with all of the quirks of winrm and powershell 3 constantly  
> > > dumping due to memory issues, I am wondering if winexe is just the way to  
> > > go for all remote shell operations...
> > > 
> > > P
> > > 
> > > On Jan 17, 2013, at 1:11 AM, "Chris McClimans" [chef@hippiehacker.org](mailto:chef@hippiehacker.org)  
> > > wrote:
> > > 
> > > winrm is disabled by default for many windows installs, including cloud  
> > > providers such as Azure.
> > > 
> > > I'm contemplating a way around this limitation by either finding a way  
> > > to turn on winrm, or just executing commands via RDP instead.
> > > 
> > > I found an interesting from blog entry from 2008\*[1] that suggested  
> > > using the rdesktop executable (on linux) to run commands/scripts.
> > > 
> > > rdesktop -r disk:local="/tmp/dir/" my.new.server -s "cmd.exe /K net use x: \\tsclient\local & x:\setupwinrm.bat & shutdown /t 0 /r"
> > > 
> > > However that obviously requires shelling out to run a binary on Linux  
> > > that requires the presence of an X server.
> > > 
> > > I was wondering if anyone has any suggestions or has seen any ruby gems  
> > > or libraries that we could use to make something like this cross-platform.
> > > 
> > > The ideal scenario would give us the ability to run commands via the RDP  
> > > procotol from plain ruby (no X or Linux required).
> > > 
> > > Then we could do something like:
> > > 
> > > knife bootstrap windows rdp my.new.server
> > > 
> > > [1]  
> > > [http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html](http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html)

---

<div class="post-metadata">

**Author:** ![Madhurranjan\_Mohaan](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@Madhurranjan\_Mohaan](https://discourse.chef.io/u/Madhurranjan_Mohaan)\
**Post date:** [January 21, 2013, 8:36am UTC](https://discourse.chef.io/t/bootstrapping-windows-nodes-via-rdp/3502/6 "2013-01-21T08:36:11Z")

</div>

Hi Chris,

We run a small recipe using windows\_batch initially to turn on and  
configure winrm. It has worked well for us. Following this , we have not  
had to RDP to any box to execute scripts. If and when needed we use knife  
windows to run commands remotely.

Ranjan

On Thu, Jan 17, 2013 at 2:41 PM, Chris McClimans [chef@hippiehacker.org](mailto:chef@hippiehacker.org)wrote:

> winrm is disabled by default for many windows installs, including cloud  
> providers such as Azure.
> 
> I'm contemplating a way around this limitation by either finding a way to  
> turn on winrm, or just executing commands via RDP instead.
> 
> I found an interesting from blog entry from 2008\*[1] that suggested using  
> the rdesktop executable (on linux) to run commands/scripts.
> 
> rdesktop -r disk:local="/tmp/dir/" my.new.server -s "cmd.exe /K net use x: \\tsclient\local & x:\setupwinrm.bat & shutdown /t 0 /r"
> 
> However that obviously requires shelling out to run a binary on Linux that  
> requires the presence of an X server.
> 
> I was wondering if anyone has any suggestions or has seen any ruby gems or  
> libraries that we could use to make something like this cross-platform.
> 
> The ideal scenario would give us the ability to run commands via the RDP  
> procotol from plain ruby (no X or Linux required).
> 
> Then we could do something like:
> 
> knife bootstrap windows rdp my.new.server
> 
> [1]  
> [http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html](http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html)

---

<div class="post-metadata">

**Author:** ![hippiehacker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/hippiehacker/32/1469_2.png) [@hippiehacker](https://discourse.chef.io/u/hippiehacker)\
**Post date:** [January 21, 2013, 6:08pm UTC](https://discourse.chef.io/t/bootstrapping-windows-nodes-via-rdp/3502/7 "2013-01-21T18:08:06Z")

</div>

Ranjan,

How do you run that initial recipe... I'm looking at targeting cloud  
providers that may not enable winrm by default... or at locations that  
already use RDP. Basically trying to find a way to bootstrap bootstrap  
nodes via available default protocols.  
Winrm rarely seems enabled by default. psexec and winexec require smb ports  
which cloud providers rarely allow access to, but RDP seems to be  
everywhere and mostly be default.

On Mon, Jan 21, 2013 at 12:36 AM, Madhurranjan Mohaan \<  
[maadhuuranjan.m@gmail.com](mailto:maadhuuranjan.m@gmail.com)\> wrote:

> Hi Chris,
> 
> We run a small recipe using windows\_batch initially to turn on and  
> configure winrm. It has worked well for us. Following this , we have not  
> had to RDP to any box to execute scripts. If and when needed we use knife  
> windows to run commands remotely.
> 
> Ranjan
> 
> On Thu, Jan 17, 2013 at 2:41 PM, Chris McClimans [chef@hippiehacker.org](mailto:chef@hippiehacker.org)wrote:
> 
> > winrm is disabled by default for many windows installs, including cloud  
> > providers such as Azure.
> > 
> > I'm contemplating a way around this limitation by either finding a way to  
> > turn on winrm, or just executing commands via RDP instead.
> > 
> > I found an interesting from blog entry from 2008\*[1] that suggested using  
> > the rdesktop executable (on linux) to run commands/scripts.
> > 
> > rdesktop -r disk:local="/tmp/dir/" my.new.server -s "cmd.exe /K net use x: \\tsclient\local & x:\setupwinrm.bat & shutdown /t 0 /r"
> > 
> > However that obviously requires shelling out to run a binary on Linux  
> > that requires the presence of an X server.
> > 
> > I was wondering if anyone has any suggestions or has seen any ruby gems  
> > or libraries that we could use to make something like this cross-platform.
> > 
> > The ideal scenario would give us the ability to run commands via the RDP  
> > procotol from plain ruby (no X or Linux required).
> > 
> > Then we could do something like:
> > 
> > knife bootstrap windows rdp my.new.server
> > 
> > [1]  
> > [http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html](http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html)

---

<div class="post-metadata">

**Author:** ![Madhurranjan\_Mohaan](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@Madhurranjan\_Mohaan](https://discourse.chef.io/u/Madhurranjan_Mohaan)\
**Post date:** [January 23, 2013, 5:13am UTC](https://discourse.chef.io/t/bootstrapping-windows-nodes-via-rdp/3502/8 "2013-01-23T05:13:06Z")

</div>

Hi Chris,

In our case we interact with Vmware infrastructure. As part of the base  
template we've added a startup job that runs chef client and in turn pulls  
the required recipes . One of those recipes is the winrm recipe . Our flow  
is as follows:  
Template -\> VM creation task -\> Vm comes up and runs customization ( where  
it joins the domain , hostnames change , it gets the ip address, licenses  
are applied etc) -\> Vm reboots and on startup it runs chef-client. If  
you're worried about what recipes to run at startup , one way is to even  
precreate the node and then assign it the required cookbooks so that it  
runs it. I hope this is of some help with your cloud provider. Let us  
know.

cheers  
Ranjan

On Mon, Jan 21, 2013 at 11:38 PM, Chris McClimans [chef@hippiehacker.org](mailto:chef@hippiehacker.org)wrote:

> Ranjan,
> 
> How do you run that initial recipe... I'm looking at targeting cloud  
> providers that may not enable winrm by default... or at locations that  
> already use RDP. Basically trying to find a way to bootstrap bootstrap  
> nodes via available default protocols.  
> Winrm rarely seems enabled by default. psexec and winexec require smb  
> ports which cloud providers rarely allow access to, but RDP seems to be  
> everywhere and mostly be default.
> 
> On Mon, Jan 21, 2013 at 12:36 AM, Madhurranjan Mohaan \<  
> [maadhuuranjan.m@gmail.com](mailto:maadhuuranjan.m@gmail.com)\> wrote:
> 
> > Hi Chris,
> > 
> > We run a small recipe using windows\_batch initially to turn on and  
> > configure winrm. It has worked well for us. Following this , we have not  
> > had to RDP to any box to execute scripts. If and when needed we use knife  
> > windows to run commands remotely.
> > 
> > Ranjan
> > 
> > On Thu, Jan 17, 2013 at 2:41 PM, Chris McClimans [chef@hippiehacker.org](mailto:chef@hippiehacker.org)wrote:
> > 
> > > winrm is disabled by default for many windows installs, including cloud  
> > > providers such as Azure.
> > > 
> > > I'm contemplating a way around this limitation by either finding a way  
> > > to turn on winrm, or just executing commands via RDP instead.
> > > 
> > > I found an interesting from blog entry from 2008\*[1] that suggested  
> > > using the rdesktop executable (on linux) to run commands/scripts.
> > > 
> > > rdesktop -r disk:local="/tmp/dir/" my.new.server -s "cmd.exe /K net use x: \\tsclient\local & x:\setupwinrm.bat & shutdown /t 0 /r"
> > > 
> > > However that obviously requires shelling out to run a binary on Linux  
> > > that requires the presence of an X server.
> > > 
> > > I was wondering if anyone has any suggestions or has seen any ruby gems  
> > > or libraries that we could use to make something like this cross-platform.
> > > 
> > > The ideal scenario would give us the ability to run commands via the RDP  
> > > procotol from plain ruby (no X or Linux required).
> > > 
> > > Then we could do something like:
> > > 
> > > knife bootstrap windows rdp my.new.server
> > > 
> > > [1]  
> > > [http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html](http://www.singularity.be/2008/03/using-rdesktop-to-script-windows.html)
