[UPDATE] Instructions below are for Windows Server 2008 which does not have PowerShell or .NET support for Server Core. Windows Server 2008 R2 released later, has native support for these, so you can simply follow these Microsoft instructions to enable PowerShell there: http://support.microsoft.com/kb/976736
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:
- Installing Visual C++ Redistributable Packages (required for .NET).
- Installing .NET 2.0 SP1
- Installing PowerShell.
- 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:
- Microsoft Visual C++ 2005 SP1 Redistributable Package (x64)
- Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)
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:
- Download .NET Framework 3.5.
- Unpack the setup to get access to the .NET 2.0 Service Pack 1 installation files.
- Download and install the Orca MSI editor.
- Use Orca to remove the Windows version check.
- 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.)
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
.
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!
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: PowerShell, PowerShell v2, Server Core, Windows Server 2008, hack
Very sweet! Too bad it isn’t supported- that means this won’t make it out of the lab because of policy. D’oh!
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.
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?
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
Awesome.
Brilliant
Thanks for this
Awesome.
You rock dude!
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.
🙂
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.
Thanks Dmitry, I’ve added a link here in the beginning of my post.
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 ?
Alright, I apologize
Reading previous posts, author gave the logical answer : install orca in another computer …
Insert it directly in the doc 😉
Thx boyz
The folders in deploy dont get filled with that script for me (windows xp sp3).
Okay, copied it to a different drive, edited the work folder in the script and it worked perfectly now.
Going to continue.
I prefer a much quicker route.
1. Download .NET Fx 2.0 Redist and right-click Extract here.
2. run “netfx.msi /qb ADDEPLOY=1 DD_IE501FOUND_X86.3643236F_FC70_11D3_A536_0090278A1BB8=True” from command-line.
Done.
DMitri
I followed your instructions and everything went fine up to the point of running the command to install .net on the server core machine.
I get a dialog box saying there is a problem with this Windows Installer Package ..Please refer to the setup log for more information.
THis is the command line I was using
C:\Windows>%SystemRoot%\system32\msiexec.exe /package “c:\downloads\NetFx20_x64\NetFx20a_x64.msi” vsextui=1
(THe machine I am installing on is x64)
Any clues on what might be stoppig the install ?
John,
Are you sure you saved the changes to the msi file (and not as another tranform)?
Also, make sure that you change the conditions in BOTH:
Regtlib.exe_Tool_____X86.3643236F_FC70_11D3_A536_0090278A1BB8
AND
Regtlib.exe_Tool_____A64.3643236F_FC70_11D3_A536_0090278A1BB8
Finally, you can try the alternative posted by MLT just above your comment.
Dmitry
MLT, wow! Looks like an easier alternative. Learning something new every day!
Couple things to consider.
1. Config hierarchy not quite there. I had to add an EXE config to the console app I ran and include a section. Apparently no where up the chain did it exist. Not surprising.
2. I tested this on a 32-bit install, not 64-bit. I will try that later when I setup the real box.
3. I am sure the eventual official install will rip out things I have yet to find that may fail, but all the basics work great.
So the reason this was left out was to reduce the footprint, attack surface, patch surface. Plus you can enable WinRM and WinRS to run PS commands and scripts from a remote system, or just target the remote system in the PS command to begin with.
So why bother?
Rob,
> So the reason this was left out was to reduce the footprint, attack surface, patch surface.
Yes and no. This is a matter of choice and to some admins PowerShell can be a great additional feature of server core improving its manageability.
With that said, the current way of installing it, described above, is for labs, rather than for production environment. Supported production procedure is coming from Microsoft and will address patching, etc.
> Plus you can enable WinRM and WinRS to run PS commands and scripts from a remote system, or just target the remote system in the PS command to begin with.
Not really. PowerShell v2 remoting requires not just WinRM, but also PowerShell v2 on BOTH ends. Without it, all you can do is basically WMI calls – a tiny subset of the functionality. QAD cmdlets also work remotely for Server Core DCs. And that is probably it.
Dmitry
I follow all your steps and everything has worked up to the point where i try to install powershell, when i try to install it it just gives me an access denied…
Any suggestions?
Access denied on Step 3? When running the msi on the server core? Can you make sure you are local administrator on the system?
Im logged in as administrator so i dont expect permissions problems, i was running the msi from an external drive so i decided to copy the msi to the c:\ drive but im still getting the same access denied. I downloaded powershellv2 ctp so im not sure if that has anything to do with it.
Hey, prety good.
Server Core is on FIRE! Important once we go live with .NET all patch work is on us like you said to Don, but I think it pays to have the BOX more manageable.
Thanks for the treat, also thanks to MAX Trinidad, Compatriota Puertorriqueno, that alerted on saving a good 15 minutes of trouble shooting on the Step By Step process of ORCAS…
Goodthings,
Isvet
BACS can run, the gui, on Hyper-V server now that 2.0 can be installed. I’ve tested it and everything works flawless. VLAN, Offloading, and teaming (with the latest drivers for your card) are easily setup now.
Dmitriy, well spoken. Awesome hack.
PS: i wrote that comment in Russian and it was getting discarded. 😦
Roman,
Thanks!
Dmitry
P.S. Don’t know why wordpress was discarding the Russian comment. Some weird antispam algorithm kicking in, I guess.
The solution doesn’t work on Windows 2008 Core with SP2 (I am unable to install .net Framework SP2 – following your article)
Mike,
That’s a pity. I obviously did everything long before the SP. I don’t have the lab to re-work the whole procedure again, but my gut feeling is that the issue is probably not with the Server SP, but probably with the change of the condition test in .NET setup. If you have time, I would recommend checking various conditions in there and disabling them.
Dmitry
Fantastic, I didn’t know about this topic up to now. Thanx!
If you are trying to do this on Windows Server Core R2, see this:
http://support.microsoft.com/kb/976736
In particular, method 1 worked for me:
Run SCONFIG.
Select option 4 (Configure Remote Management).
Select option 2 (Enable Windows PowerShell).
Click OK.
Steve,
This post was back from early 2008. 🙂 So all the instructions apply to Server 2008 – not R2 which indeed has native support.
I think I need to update it with the link you posted so people do not get confused. Thanks for the reminder!
Dmitry
PowerShell v2 CTP2 is available from Microsoft’s downloads page.
d’not work
Right on!
Awesome,
Thanks Dmitry.
I found this, working on something for school; it doesn’t unpack the files for the .Net Framework (2.0, 3.0 or 3.5). Yes, I put all the downloads in the correct folder and run the deploy.com script from there, but still nothing.
Anderw
I have not been doing this for a while now that Windows Server 2008 R2 supports PowerShell on core natively. So yes if Microsoft changed some of the packages since then, I guess you need to find how to get the files from the new ones. Please post back the info if you manage to find the new way. Or switch to R2.
All you are doing is just copying the work of someone else (Artem Pronichkin) which is originally written in Russian and translating it to English and grabbing attention. Since this post is in English, this post has gotten more attention than the Russian one which is not that understandable by everyone.
See link: http://pronichkin.com/Lists/Posts/Post.aspx?ID=69
If you Ctrl-C, Ctrl-V the original post section by section in Google Translate, anyone will see that you have done zero effort on this other than that of the job of a translator. I know you have given the name of the original author in this post, but it is sad to see most of the credit goes to u, not to the original person who actually made the effort to make this possible.
In the acknowledgements: you actually said that Artem Pronichkin helped you, but that is not correct. You just actually stole his work and then translated it and made it a post of your own which is too smart, but he deserves much more than this…
I believe, whatever you are claiming you have done, anyone can do it since Google Translator can translate any language to English….LOL
How to install PowerShell on Windows Server 2012 R2 Core
http://winplat.net/2016/01/08/how-to-install-powershell-on-windows-server-2012-r2-core/
Can’t find PowerShell v2 CTP2 to download. I need it for Windows 2008 Server Core.