Monday, October 4, 2010

Getting Powershell started on Windows Server 2008 r2 Core

Thought I should check out how the command line based Windows Server works out, so I decided to install it virtually. I've just started to check out Powershell, so configuring and adminstering a Core installation is not something I know how to do, but you'll never learn anything if you don't dare experiment a little. Anyway, this post is just going to be some notes I make along the way of getting started. I should also be noted that I haven't done much of scripting on Windows, so I am to be considered a total noob on this subject :)

The easiest way to start the intial configuration of the server is using the utility sconfig. This utility makes you able to do the basic configuration in an easy way; setting up hostname, domain, IP-settings and so on. To get startet just type the following command in the shell;
sconfig
And the following screen will show up which is quite self explainatory:



Even though the system is kind of basic when it comes to hardware needs, you still would want to install drivers. The easiest way to do that (as far as I've found out) is to just insert the driver cd-rom and run the setup utility from there. To install the guest additions for VirtualBox i just added the iso to the VM and started the installation program. After a reboot the drivers seems installed and everything works as expected (video, mouse integration and so on).

As default we see that the shell in use is command.com and not Powershell. I am quite sure that administering a server from command.com must be for people who wants to torture themselves, so lets try to get Powershell running. By default this is not installed, so we need to get that done. Bur first we need to install the required .NET-2.0 and .NET.3.0. To get a list of available components you can use 
oclist

Of course the buffer size is so small that you can't scroll up to the first entries. The solution would be to use pipe (|) and send the output through more:
oclist | more

So lets continue by install the required .NET packages (one important note; command.com have suddenly become case-sensitive!, I did not get that memo, so I had some trouble figuring out why I couldn't get it installed, but when I used the right case it worked. :
ocsetup NetFx2-ServerCore
ocsetup NetFx3-ServerCore

We don't get any progress bars or anything, so we just have to guess when it's finished (or you can push ctrl+shift+esc to get to Task Manager, and just watch the processlist).


And finally we install Powershell:
ocsetup MicrosoftWindowsPowerShell

To start Powershell the following command will do:
c:\windows\system32\WindowsPowerShell\1.0\powershell.exe

Don't let the 1.0 part fool you, it is Powershell 2.0 that you got at your hands :)

Now we can start exploring Powershell and see what it can do and how it works. My first impressions can be summarized like this:
I miss Bash :)
But I guess that if are going to administering Windows Servers (core or standard) it's not a bad thing to know a little about Powershell. A future post will contain what I've discovered while trying to figure out how it works.

No comments:

Post a Comment