PowerShell on Server Core

Below is a step-by-step instruction on installing Windows PowerShell on Windows Server 2008 in Server Core mode.

Note that these are in no way official or supported by Microsoft. Microsoft is working on official version of .NET and PowerShell for Server Core installations, so eventually you will be able to get this fully supported. Until then below are the instructions you can use at your own risk, etc., etc.

Quick Introduction

Windows Server 2008 has a command-line installation option - Server Core - which significantly reduces the attack surface and patch requirements by the virtue of not having Explorer and other UI components not needed in datacenter.

The problem is that it only ships with traditional cmd.exe and not PowerShell. To make things worse neither PowerShell nor .NET as they are today can be installed on such systems.

Below are the steps you can take to create packages of these tools which can be installed. Basically the whole procedure consists of just four main steps:

  1. Installing Visual C++ Redistributable Packages (required for .NET).
  2. Installing .NET 2.0 SP1
  3. Installing PowerShell.
  4. Jumping around the computer and shouting “I’ve got it!”

So let’s get started!

1. Visual C++ Redistributable Packages

This is the easiest one. All you need to do is download the packages you need:

After that, copy these files to your Server Core computer (e.g. using Robocopy) and simply run them there.

If your Server Core is 32-bit - just run vcredist_x86.exe.
If it is 64-bit, you need to install both x86 and x64 versions (vcredist_x86.exe and vcredist_x64.exe).

2. .NET Framework

This is the most tricky part. PowerShell needs .NET 2.0 and .NET 2.0 is supposed to be a component of Windows Server 2008 so we will have to get a package of the framework which can get installed on such a system. To accomplish that we will:

  1. Download .NET Framework 3.5.
  2. Unpack the setup to get access to the .NET 2.0 Service Pack 1 installation files.
  3. Download and install the Orca MSI editor.
  4. Use Orca to remove the Windows version check.
  5. Run the updated MSI.

2.1. Download .NET: Go to Microsoft’s web site and download full redistributable package of .NET 3.5.

2.2. Unpack the file:
a. Create a folder c:\deploy
b. Save the downloaded .NET framework package to this folder.
c. Download the wonderful deploy.cmd script which Artem has posted and put it into the same folder.
d. Run the script.

After the script executes, the C:\Deploy\AIP folder will have both NetFx20_x64 and NetFx20_x86 folders with .NET 2.0 framework files you need.

2.3. Install Orca:

This is great but unfortunately you cannot just install the files because the MSIs are specifically checking for Windows version. So now we need to disable this check. To do this we will use Microsoft’s Orca MSI editor.

Note: This all needs to be done on a regular, not Server Core, machine. We will copy the results of our Orca operations to the Core box later on.

If you don’t have Orca, follow these steps to download it:
a. Download the Windows SDK for Windows Server 2008 and .NET Framework 3.5 installer.
b. Run the installer and deselect everything except Win32 Developer Tools (this will make sure that you only download the few megs you need.)

Downloading Orca

c. After the installation completes, go to C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin and install Orca.msi.

2.4. Tweak the setup:

Now its time to do some patching.
a. Start Orca and open the MSI you need (C:\Deploy\AIP\NetFx20_x86\NetFx20a_x86.msi for 32-bit version or C:\Deploy\AIP\NetFx20_x64\NetFx20a_x64.msi for x64).
b. Click Component.
c. In x86 locate: Regtlib.exe_Tool_____X86.3643236F_FC70_11D3_A536_0090278A1BB8
In x64 locate that one and Regtlib.exe_Tool_____A64.3643236F_FC70_11D3_A536_0090278A1BB8
d. Change the Condition from (VersionNT < 600) or Version9X to just VersionNT or Version9X.

Allow .NET 2.0 Framework to get installed on Windows Server 2008

e. Save changes (either to that same MSI or a transform file.)

2.5. Install .NET

Copy the files (the whole folder) to your core machine and start the MSI via this command line (note that you need to use msiexec in order to pass the vsextui=1 parameter):

If you saved a transformed file and are running 64-bit version you will probably run:
%SystemRoot%\system32\msiexec.exe /package "NetFx20_x64\NetFx20a_x64.msi" vsextui=1 transforms="ServerCore.mst"

On x86 without a transform that would be:

%SystemRoot%\system32\msiexec.exe /package "NetFx20_x86\NetFx20a_x86.msi" vsextui=1

That’s it. Now we have .NET installed and can go to the final step - PowerShell installation!

3. Windows PowerShell

There is no PowerShell v1 setup for Windows 2008 (again, because it is supposed to be a component) but you can actually download and install the CTP (note: this is a pre-beta code - not for production use). PowerShell v2 CTP2 is available from Microsoft’s downloads page.

Download the version you need, copy the msi over to the Server Core box and simply run the msi.

4. Enjoy!

Now you can start PowerShell!

Just run:
c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

And you will see the prompt change to: PS C:>

That’s it. Now you are among the first geeks in the Universe to have PowerShell on Server Core!

PowerShell v2 running on Windows Server 2008 Server Core

Acknowledgments: I could only have this all accomplished thanks to the help I got from Alex Kibkalo and a great post by Artem Pronichkin on installing .NET on Server Core.

Tags: , , , ,

37 Responses to “PowerShell on Server Core”


  1. 1 Preston May 15, 2008 at 5:55 pm

    Very sweet! Too bad it isn’t supported- that means this won’t make it out of the lab because of policy. D’oh!

  2. 2 Max Trinidad May 15, 2008 at 6:16 pm

    GREAT Article!!! This is awesome. I knew that its possible and now you gave steps in How-to. I will be putting it to work within the next few days. Thanks.

  3. 3 don May 15, 2008 at 8:11 pm

    what does this do to maintenance? Will software update patch these hacked-in components? If not this seems to defeat the whole small-footprint lower-maint goal of server core. Does psh on core offer an advantage? Wouldn’t it push toward local management rather than remote, as intended?

  4. 4 dmitrysotnikov May 15, 2008 at 8:17 pm

    Don,

    Please read the post again. Right now this is an unsupported configuration. If you deploy it you have to take care of patching, etc.

    When official package is released by Microsoft you will obviously be able to rely on their patching.

    PowerShell on core (especially when cmdlets become available for core specific management) will offer significant advantages over the current set of utilities managed from cmd.exe. Are we there already? Not yet, but this is coming and will eventually make Server Core a much more compelling story.

    Dmitry

  5. 5 matthew May 16, 2008 at 12:08 am

    Awesome.

  6. 6 Richard May 16, 2008 at 8:45 am

    Brilliant

    Thanks for this

  7. 7 thomas lee May 16, 2008 at 3:49 pm

    Awesome.

    You rock dude!

  8. 8 Max Trinidad May 17, 2008 at 6:48 pm

    Dmitry, once again for a great blog. I found myself some pitfalls in the section of upackaging the .NET Framework 3.5 so I blog on the steps for those who might end up in the same situation. Now, I can remotely connect to my test Server Cores and run PowerShell scripts. :)

  9. 9 dmitrysotnikov May 18, 2008 at 6:27 pm

    Thanks Max! I guess I should have been more explicit in the Orca section: Yes, Orca needs to be installed and used on a regular computer, and you only need to copy the processed files to the Core afterwards.

  10. 10 Pronichkin May 19, 2008 at 7:21 am

    Thanks Dmitry, I’ve added a link here in the beginning of my post.

  11. 11 laszlo May 22, 2008 at 5:23 pm

    Strange, trying to execute SDK setup.exe application warns me it cannot be installed because it needs Framework 2 in order to continue.

    Well, recapitulating, I use SDK in order to install Framework but SDK need Framework to be installed … I get crazy lol

    Any idea of what’s happening ?

  12. 12 laszlo May 22, 2008 at 5:25 pm

    Alright, I apologize

    Reading previous posts, author gave the logical answer : install orca in another computer …

    Insert it directly in the doc ;)

    Thx boyz

  13. 13 Daitox June 15, 2008 at 7:08 am

    The folders in deploy dont get filled with that script for me (windows xp sp3).

  14. 14 Daitox June 15, 2008 at 7:11 am

    Okay, copied it to a different drive, edited the work folder in the script and it worked perfectly now.

    Going to continue.

  1. 1 PowerShell on Server Core - Rod Trent at myITforum.com Trackback on May 16, 2008 at 5:34 pm
  2. 2 markwilson.it » PowerShell running on server core Trackback on May 16, 2008 at 9:40 pm
  3. 3 Tim Anderson’s ITWriting - Tech writing blog » Installing .NET, PowerShell on Windows 2008 Server Core: it can be done Trackback on May 17, 2008 at 9:16 am
  4. 4 Vlad Mazek - Vladville Blog » Blog Archive » PowerShell to the Core (2008) Trackback on May 18, 2008 at 11:23 am
  5. 5 PowerShell on Server Core « Dmitry’s PowerBlog: PowerShell and beyond - Kurbli Trackback on May 18, 2008 at 1:21 pm
  6. 6 TechNet Team Blog Austria : PowerShell auf Windows Server 2008 Server Core Trackback on May 18, 2008 at 8:16 pm
  7. 7 PowerScripting Podcast - Episode 26 « PowerScripting Podcast Trackback on May 19, 2008 at 2:02 am
  8. 8 Gaidar Magdanurov : PowerShell на Windows Server 2008 Server Core Trackback on May 19, 2008 at 6:48 am
  9. 9 The things that are better left unspoken : Looking for .Net and Powershell on Server Core? Trackback on May 19, 2008 at 7:14 am
  10. 10 Expert Texture » .NET on Server Core Trackback on May 19, 2008 at 2:22 pm
  11. 11 Instalar Powershell en Windows 2008 Server Core - Eladio Rincón, SQL Server MVP Trackback on May 19, 2008 at 3:34 pm
  12. 12 Schweizer IT Professional und TechNet Blog : PowerShell auf Server Core: unmöglich! Oder doch nicht? Trackback on May 19, 2008 at 7:00 pm
  13. 13 PowerShell не стоит на месте « PowerShell и другие скрипты Trackback on May 20, 2008 at 4:52 pm
  14. 14 PowerShell on Windows Server 2008 Core Edition - Network Administrator Knowledgebase Trackback on May 21, 2008 at 2:45 am
  15. 15 » Blog Archive » PowerShell on Server Core Trackback on May 22, 2008 at 11:35 am
  16. 16 Running Powershell On Windows Server 2008 Core « the back room tech Trackback on May 22, 2008 at 5:31 pm
  17. 17 Блог Гайдара Магдануров : PowerShell на Windows Server 2008 Server Core Trackback on June 2, 2008 at 3:06 pm
  18. 18 Power Shell on Windows Server 2008 Core!!! | Far beyond the world Trackback on June 7, 2008 at 11:28 pm
  19. 19 Robert McLaws: Windows Vista Edition : Windows PowerShell (and .NET) on Windows Server 2008 Core Trackback on June 12, 2008 at 3:17 pm
  20. 20 Набор отверток для Windows Server 2008 Core | AboutDigital Trackback on June 12, 2008 at 4:27 pm
  21. 21 Live PowerShell with Karl Prosser (Mirror) » Blog Archive » Portable PowerShell - v1 and v2 side by side - even on Server Core. Trackback on June 18, 2008 at 4:45 am
  22. 22 Live PowerShell With Karl Prosser » Blog Archive » Portable PowerShell - v1 and v2 side by side - even on Server Core. Trackback on June 18, 2008 at 4:47 am
  23. 23 Running portable PowerShell V1 and V2 side by side on Server Core » D' Technology Weblog: Technology, Blogging, Tips, Tricks, Computer, Hardware, Software, Tutorials, Internet, Web, Gadgets, Fashion, LifeStyle, Entertainment, News and more by Deepak Trackback on June 19, 2008 at 8:15 am

Leave a Reply