31

How do I enable a serial console on Windows (2008 and/or 2012) such that I can log into it like the Good Old Days of Real Servers and issue provisioning commands, ideally via PowerShell?

$ cu -l /dev/ttyS0
Connected.

Welcome to ad1.adlab.brazzers.com

Microsoft Windows [Version 6.1.7601]
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

Login: Administrator
Password: 

PS C:\Users\Administrator> New-NetIPAddress –InterfaceAlias eth0 –IPv4Address 192.168.101.11 –PrefixLength 24 -DefaultGateway 192.168.101.1

PS C:\Users\Administrator> 
MikeyB
  • 38,725
  • 10
  • 102
  • 186

1 Answers1

39

Wow, well, what you want is called Emergency Management Services (EMS) redirection.

http://msdn.microsoft.com/en-us/library/ff542282(v=vs.85).aspx

And it works on modern versions of Windows.

In XP/2003, enabling it would look like

bootcfg /ems on /port com1 /baud 9600 /id 1

On Windows Vista/2008+ it is enabled by typing the following command where {default} is the OS entry in BCDedit:

BCDedit /bootems {default} ON

The following commands set the global EMS redirection settings to use COM2 and a baud rate of 115200, and enable EMS for the specified boot entry.

bcdedit /emssettings EMSPORT:2 EMSBAUDRATE:115200

Something that not many people know is that you can still connect to a Windows computer using EMS and perform a few administrative functions even after the computer has experienced a STOP/bugcheck/BSoD!

Powershell? I don't know about that... I kinda' doubt it, but who knows. The envisioned usage for EMS is after everything else has failed, but you can get a cmd.exe shell with EMS... and you can type powershell.exe from a Cmd.exe shell... so maybe.

That's the best Microsoft-native thing you're gonna get. Otherwise you are looking at third-party software for running a server over a COM or USB port.

The book Windows Server 2008 R2 Secrets By Orin Thomas has a decent section on EMS, which is actually freely Googlable.

Edit: Verified, Powershell is possible through EMS!

PS: You're nuts!

Ryan Ries
  • 55,011
  • 9
  • 138
  • 197
  • 1
    Sweet! Nice to know how to do it. Here's what it looks like: https://gist.github.com/Supermathie/7423949 – MikeyB Nov 12 '13 at 01:44
  • Awesome. I've never seen EMS used in a production environment. Only by kernel debuggers and device driver writers have I ever seen it used. But more power to you! I'd upvote this question twice if I could. :) – Ryan Ries Nov 12 '13 at 01:48
  • I'm a bit gobsmacked that there's no "just a serial console" option in EMS. That would be *useful*. – MikeyB Nov 12 '13 at 15:06
  • Well, Windows doesn't really have a command line in normal operations. It doesn't have runlevels like Unix. It is GUI to the core. – mfinni Nov 12 '13 at 20:28
  • 3
    @mfinni Not entirely true in today's module-based Windows. Look at Server Core or Hyper-V Server (the standalone free hypervisor). Windows is pretty lean and slowly pulling away from GUI dependence thanks to PS. – Ashley Nov 12 '13 at 21:54
  • I'm very aware of those. They have removed as many GUI elements as possible, it's true. That doesn't change the architecture. – mfinni Nov 12 '13 at 22:49
  • @mfinni You can run a MinWin system that consists of 100 files and has a disk footprint of 25MB. And that system can run an HTTP server. So I don't think the architecture is as abysmal as you seem to imply... – Ryan Ries Nov 12 '13 at 23:03
  • Oh lord. I didn't say "abysmal" either. I'm simply (and repeatedly) saying that Unix has runlevels and the GUI is an add-on. The serial console has always been a native (and sometimes only) way to talk to a Unix machine. Windows NT has no real parallel to that - when you are using CMD, that's not a "lower level" (as opposed to Win9x and DOS). There's nothing in normal Windows NT that can be easily and simply redirected to serial. EMS is not a normal Windows shell either; it's a special limited environment. – mfinni Nov 13 '13 at 00:15
  • @mfinni In the past it looks like there was a 'ctty' command in DOS and windows before XP. It did exactly what I was looking for. – Wyatt Ward Feb 08 '16 at 02:00