James O'Neill's Blog

January 25, 2009

PowerShell 2, Server Core R2 and Hyper-V server R2

Filed under: Powershell,Virtualization,Windows Server,Windows Server 2008 — jamesone111 @ 7:01 pm

With all the betas out at the moment I’ve been trying to get up to speed on both Windows 7 (by using it) and Windows Server 2008 R2 , and Hyper-V server R2 as well.

If you’re a regular reader you won’t be surprised to know that I’m excited by what’s coming in PowerShell. PowerShell V2 is better in a lot of regards,although I’m not getting the best out of it yet. Quite aside from the graphical editor, the additional cmdlets, and the restored ability of Windows to drag and drop a file into a command window. It’s got better tab expansion. PowerShell has its own function you can customize for tab expansion, and there are two improvements in V2. The first is that tab expansion finds functions you have written as well as built in cmdlets. Much typing and confusion saved there… but something I only noticed today is that it expands parameters: can’t remember if you named a parameter “-Path” or “-VHDPath” just type the – sign and hit [Tab] and it cycles through the list. It sounds like a feeble reason to upgrade but trips back to a script file to find a parameter add up to a fair old chunk of time saved.

The other thing which is big news is the ability to run PowerShell on Core and on Hyper-V server. Unlike the full servers PowerShell is not installed by default (I’ve no idea why it is on one and not the other). Of course you shouldn’t be going the console of a Core / Hyper-V server box to do admin. But the ability to “remote” PowerShell  is a biggy. If PowerShell is installed AND remote management via WinRM is enabled then you can run any PowerShell command on a box in your data centre from your desktop machine. Of course from my point of view the this is a great push for my PowerShell library for Hyper-V on Codeplex – incidentally an update has been waiting for me to put the finishing touches to it since before Christmas and should appear shortly.

I’ve been looking at the Hyper-V configurator from R2

                            Hyper-V Configuration



1) Domain/Workgroup:                    Workgroup:  WORKGROUP

2) Computer Name:                       WIN-75FRHHINP4U

3) Network Settings

4) Add Local Administrator

5) Windows Update Settings:             Manual
6) Download and Install Updates
7) Remote Desktop:                      Enabled (all clients)
8) Failover Clustering Role             Enabled
9) Configure Remote Management

10) Regional and Language Options
11) Date and Time

12) Do not display this menu at login
13) Log Off User

14) Restart Server

15) Shut Down Server

16) Exit to Command Line

Some of the things it does are native PowerShell commands, for example V2 has commands for renaming a server, adding it to a domain, rebooting it and shutting it down

Rename-Computer –New “Core-27” 


Add-Computer –DomainName “Contoso” –Reboot



Are all pretty easy to understand – Not many people I meet can give me the command lines for NetDom and Shutdown to do the same things. Three more commands cover the regional/language and Date/Time options and logging off

control.exe “intl.cpl”

control.exe “timedate.cpl”



So what about the other options. Remote Desktop,  Networking, Cluster installation, Windows Update (settings and download) , Adding local Admins and configuring Remote Management ? If NetDom and ShutDown aren’t easy to remember, NetSH, ScReg, WinRm and the others are worse. Well I’ve been coding them up, and a couple of hundred lines thrown together over the weekend do what it took a coupe of thousand lines of VBscript to do. That’s not entirely a fair comparison because the VB Scripts which come with the OS are designed to be portable across languages, provide help and catch errors way beyond what I do in PowerShell.

I’ll break that code into a bunch of easy to digest posts over the next few days.

This post originally appeared on my technet blog.

Blog at WordPress.com.

%d bloggers like this: