James O'Neill's Blog

June 30, 2008

The Windows Server Virtualization Validation Programme

Filed under: Virtualization,Windows Server,Windows Server 2008 — jamesone111 @ 11:53 pm

I’ve mentioned this program a couple of times, and now on the Windows Server Catalog site we have a page which shows which vendors are testing their Virtualization products so they are qualified as just another "machine" on which Windows runs… As I find I keep saying we shouldn’t care much if the machine is physical or virtual. We already have a KB article which lists the vendors, that we have a joint support arrangement with. And its short, the validation programme’s page lists 4 more vendors we’re working to qualify. There are a couple missing, but I guess they don’t feel the need to work with  us to verify Windows on their platform.

On the Hyper-V side we’re talking to other operating system Vendors (e.g. Red Hat) about the steps of getting them on the supported list for Hyper-V. Sean has a great post showing different (unsupported) Linuxes running nicely on HyperV. Not supported – i.e. no joint support calls for cross vendor problems, but working none-the-less.

This post originally appeared on my technet blog.

Finding Hyper-V servers in your domain

Filed under: Powershell,Virtualization,Windows Server,Windows Server 2008 — jamesone111 @ 11:40 pm

One of the advantages of having Virtualization integrated with Windows is that the Hyper-V (and in fact Virtual Server 2005) registers itself in active directory so you can discover your servers easily – quite useful if servers start popping up like mushrooms. 

John Howard has been tracking the number of registered servers on the Microsoft corporate network for a while now, and he shared his VB script internally a little while ago, and has now posted it on his blog,

I’ve reworked it to run in PowerShell, and I got a shock when I found how many machines in my Domain were running HyperV. Lots

function get-vmHosts 

{param ($domain=([adsi]('GC://'+([adsi]'LDAP://RootDse').RootDomainNamingContext))) $searcher= New-Object directoryServices.DirectorySearcher($domain) $searcher.filter="(&(cn=Microsoft hyper-v)(objectCategory=serviceConnectionPoint))" $searcher.Findall()   | foreach {$_.path.split(",")[1].replace("CN=","")} }

#Example get-vmhosts  "DC=ite,DC=contoso,DC=com" | foreach {$_; list-vmstate -server $_} #                      Queries the domain ITE.Contoso.com for Hyper-V servers,
# prints the name of each and dumps the state of VMs on each

I’ve added this to the latest drop of my Hyper-V library which I will post to CodePlex towards the end of this week.

This post originally appeared on my technet blog.

June 27, 2008

Hyper-V. Of course it *had* to be yesterday

Filed under: Virtualization,Windows Server,Windows Server 2008 — jamesone111 @ 2:40 pm

If you’re in the UK there’s still time (just) to get last week’s Money programme about Bill Gates and the end of an era from www.bbc.co.uk/iplayer . I was away when it was broadcast and nearly forgot.

I blogged Bill’s announcement when he made it, and we’ve had two years to get ready for today. Anything releasing today would get lost. Hyper-V couldn’t go out today.  But it’s the last product we ship with Bill at the helm.

This post originally appeared on my technet blog.

Off topic. The not so sweet FA.

Filed under: General musings — jamesone111 @ 1:40 pm

For me to write a post about football (or Soccer if you prefer) – even on a Friday – is a pretty odd occurrence. I played Rugby instead and I’m not even an armchair fan of the game – would rather watch Motor Racing. I belong to that contingent who are pleased that England aren’t in the European championships (and no I don’t mean "Scots" by that). With EU employment law used to remove the requirement to have home grown players, and the Top clubs awash with TV money (Rupert Murdoch famously called sport "a battering ram" to get his satellite  TV into homes) so they can buy the best players from anywhere the poor state of the national side can’t really come as a surprise.

The football association – oddly – has the job of looking after the super rich clubs, the national team and the grass roots: things like children’s football. And the last is something I do something about. A year or so ago one of the Fathers at my daughters school decided it was high time we had a village team* and set about getting a mixed under 8s team together. Some of the team members would have qualified for under 7s. Sadly, after a year the team looks like it might not have a future because only allow 8 year olds will be allowed to play in the under 9s group. The village it looks as if the Village won’t be able to muster enough 8 year olds,nor enough 7 year olds to have a team in either group. Today the BBC has a news story "Football leagues ban for Under 8s" So I wonder if the rule is that under 8s can’t play in competitive league – so this is only a quirk of the under 9s bracket.

Under 8s football will still have goals, the teams will keep track of who scores the most goals. So each game will be every bit as competitive (we won’t get the spectacle of the uber-PC sports day where children can not race each other – even though they race in the playground every other day of the school year).  Organization of fixtures means that the teams will all play each other; yet tabulating the results is frowned upon. "The FA said there was too much emphasis on winning leagues, when the need was to improve youngsters’ skills." One has to ask how one goes about winning a league without skills. Where would are national team be if they didn’t worry about results as whole ? Sitting at home watching the European championship on TV probably.

 

 

*Update. Both our coaches had to go through CRB checks – see this story – one more barrier to getting anything off the ground.

This post originally appeared on my technet blog.

June 26, 2008

What operating systems are supported on Hyper-V ?

Filed under: Virtualization,Windows Server,Windows Server 2008 — jamesone111 @ 8:56 pm

I’ve explained before that Supported means "We are in a position to get a fix if a fault is found". Lots and Lots of operating systems are compatible with Hyper-V. Supported means we underwrite the OS with a fix guarantee. Although there is a strong correlation between "having integration components" and "supported" they are not quite the same thing. One of the things the product group have done is to test specific OS releases, in different CPU version (x86, and x64), single and Multi-CPU, with particular service packs. The list will change over time but the current list is in KB 954958.

Here’s a Tip. Don’t use the link I just gave, Search Microsoft.com for 954958. Why ? Because that will turn up future KB articles which refer to it, not just the article itself.

This post originally appeared on my technet blog.

Are people already ganging up on VMware ?

Filed under: Virtualization,Windows Server — jamesone111 @ 8:26 pm

I think with Hyper-V we’re going to please an awful lot of people, but not everybody. There are some people who will need features Hyper-V doesn’t have – indeed the future of VMware depends on the fact.I don’t want to make the mistake of underestimating a competitor, and write their obituary too early. 

Then last week IDC sent out something titled "Is VMware the new Netscape" (posted, here – registration needed ). Ouch. One of the memorable quotes I had from my friend David during the Microsoft / Netscape wars – before I worked at Microsoft – was "There are two companies in the browser business. One has a huge market share, an overrated product and treats its customers with contempt. And the other one is Microsoft".

Then today: someone sent round a link to a story on PC World – Kiss VMware’s rump goodbye. Say no more.

Update: OK, more. Someone at ZDnet has been having fun with the graphics for Jason Perlow’s take on this story

 

Technorati Tags: ,,

This post originally appeared on my technet blog.

Hyper-V released !

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

Over the last few days there have been rumours of the imminent release of Hyper-V, and now the news is officially on PressPass. In the next few minutes the following links will go live.


Windows Server 2008 x64 Hyper-V Parent Partition This package is permanent.  Once installed, it cannot be uninstalled.


Windows Server 2008 x86 Management package. This package provides the management tools only for Windows Server 2008 x86This package is also permanent.  Once installed, it cannot be uninstalled. 


The Windows Vista SP1 x64 Management package.


The Windows Vista SP1 x86 Management package.


And in a few days the update will go onto Windows update.


I have been saying privately since the Beta of Hyper-V broke cover before the RTM of Windows Server 2008 that the team was looking good to beat their “within 180 days”  deadline and that my hunch was they would want to get it done by the time our financial year ended on June 30th. Between the first Alpha builds that I saw and the beta, features were “deferred” – meaning they can be expected to return; there is a saying “to ship is to shave”; not everything you think will be in when you start work is there when the product is released. I knew they wouldn’t want to keep cutting and would only ship if the quality was right. My experience with the quality and performance has great even in the early versions – which isn’t to say the early builds were of shipping quality, simply that the flaws in them didn’t affect me. I know there are some performance numbers in the works, I’m not going to quote them here (partly because it’s someone else’s work for them to announce, and partly without explaining how the test was done “hyper-v achieves X” isn’t meaningful)*


I’ve only been to one “Ship party” in Redmond and I have this vision of product teams picking their way through the debris the following day, sitting down with a very strong, very black cup of coffee and a packet of Asprin, taking a deep breath and saying  “OK then, the next version ….”.  I’ve got some idea what’s on the wish-list for the next release (indeed Bob Muglia has commented on it), though when that will come is not something anyone is ready to talk about yet.  The next big step is the release of System Center Virtual Machine Manager 2 – which will not only manage Hyper-V, but also VMware.


We had a discussion among  Microsoft’s evangelists recently: between those who felt we were bought and paid for – and so were duty bound to evangelist anything Microsoft; and those who evangelise from the heart. I’m in the latter camp –  I take doing things from the heart to the level of a personality defect. Anyone looking back over the last year of posts will be in no doubt that I think Hyper-V is a fantastic product, it’s one I’m thoroughly pleased to be evangelising.


* Update QLogic are talking performance numbers on Hyper-V, between 90 and 97% of native performance. Update 2: (for those who don’t see comments) a better Q Logic Link http://www.qlogic.com/promos/products/hyper-v.aspx (thanks Vina)


This post originally appeared on my technet blog.

June 25, 2008

Setting up Domain controllers on Server Core.

Filed under: How to,Windows Server,Windows Server 2008 — jamesone111 @ 9:55 pm

One of the things I have pointed people to a few times recently  is the Windows Server Core document in the step by step guides for Server 2008. Want to know how to install a role ? It’s in there. Configure TCP/IP from the command line ? That’s there too. Put in the key that you skipped during installation ? You got it.

Fantastic. It’s the repository of all knowledge and wisdom … Except, to set up a domain controller, it tells you to run DCPROMO with an unattend file. What goes in the file ? I’ve carefully avoided this ….

Right at this moment I’m trying to prepare a presentation for the morning. I found a great way of explaining objects over the on the PowerShell blog: I was always told that plagiarism was the sincerest form of flattery and I was planning to flatter Ben who produced it. Sadly the slide deck isn’t linked to from his blog (and proving that I’m a complete numpty I missed the Link on the bottom of the PowerShell blog post)What I did find on Ben’s blog was How to Configure a Server Core Domain Controller: a-ha ! Better still it gave me something I could throw into a search and that turned up  KB 947034: How to use unattended mode to install and remove Active Directory Domain Services on Windows Server 2008-based domain controllers. Problem solved.

This post originally appeared on my technet blog.

June 18, 2008

Hyper-V PowerShell library – now on Codeplex

I’ve decided to go ahead and post the PowerShell library I have been working on to Codeplex. I wanted to explain various bits of it here before pulling it all together, but that is taking more time than I wanted. I’ve provided early copies to a few people – John Kelbley  used them to good effect at the US tech-ed recently – and I haven’t had too many bug reports so I’ve decided to broaden the audience. 

There’s lot’s of good stuff happening in Hyper-V and scripting right now. Taylor Brown has a blog with more examples in PowerShell; Ben Armstong has some good stuff too; Ben’s more of a VB guy than a PowerShell one and I’ll probably continue to tease him gently about the fact … he has a very long script. to compact a VHD. Mine is a 4 line function.  Interestingly Taylor’s post contains a "Wait for WMI Job" function and Ben has built in. I might write a similar function and give my functions which return Job IDs a "-WAIT" option in the next major revision. I picked out Taylor and Ben because of their blogs but there have been other people inside Microsoft who have been a great help pulling this together, I wish I’d kept a list of who had pointed me to this or that so I could thank them.   

The source code is open (as Powershell tends to be) and distributed under the Microsoft public license (MS-PL).

This post originally appeared on my technet blog.

Scripting Sysadmin meme

Filed under: Uncategorized — jamesone111 @ 11:52 am

In response to Steve’s Scripting/Sysadmin Meme and Richard’s call out … I’ve answered the questions, but I’m not going to tag anyone else.

How old were you when you started programming?

I was 12. I think my very first program calculated factorials

What was your first machine?

The School had a Digital PDP 8/f. You had to toggle switches on the front panel to start it up, and if you got it wrong you had to reload the OS and BASIC interpreter from Paper tape. Not surprisingly they moved onto Commodore PETs. We had a Sinclair Spectrum at home but it wasn’t mine. The first computer that I could call my own was an RM Nimbus of some kind when I started work there.

What was the first real script you wrote?

Script rather than program… probably something in the Job Control language used by the Cray-1 I was allowed to borrow when I was a student in 1986/7

What scripting languages have you used?

DOS-Batch, Novell’s login Script language (NetWare 2.0a – 3.11), VBscript, Powershell – really quite a lot of PowerShell – I can read Javascript, but I can’t really write it. In my time I’ve used various forms of Basic, Pascal, Lisp, Fortran, Occam and Forth. The biggest project I ever did was in Access Basic, the first time I ever called a DLL was from Excel, and my initial experience with COM objects was getting various bits of office to work with each other. I never learnt C or C++ and my C# is read only as well

What was your first professional sysadmin gig?

Depending on your definition of Sysadmin, fixing a stack of code for an Actuary when I was still at school, most of that was Microsoft Basic on the Apple II, but later it became Lotus Macros and DOS batch files.

If you knew then what you know now, would you have started in IT?

Sorry, but I think that’s a daft question. Given my time again I’d have married my wife earlier than I did, had kids earlier than we did and joined Microsoft earlier than I did. But you make your decisions with the information you have at the time and live with them. If I’d known how tough some things were going to be (e.g. running a small Microsoft partner for 5 years), I would have looked for something easier and  missed out on a lot.

If there is one thing you learned along the way that you would tell new sysadmins, what would it be?

Remember why you’re there. IT should get help get business task done quicker, more reliably, more easily and with less drudgery. If you find you’re hindering these things rather than helping them…. get out. 

What’s the most fun you’ve ever had scripting?

It’s like solving a sudoku or crossword or some other Puzzle more than it is like climbing a mountain. You might look back and say what is the greatest Peak you climbed, but the greatest puzzle you ever  solved ??? Recently I wrote some Powershell to match my underwater photos to the information in my Scuba Dive log, and use it to set the title in the EXIF data in the picture. I was jolly pleased with that, but like doing the Christmas giant crossword it will fade.

This post originally appeared on my technet blog.

June 17, 2008

Security, Security, Security.

Filed under: General musings,Security and Malware — jamesone111 @ 5:38 pm

The story last week that someone had left a secret folder of documents on a train – which were then given to the BBC brought back memories for me. Shortly after my wife and I had moved into our first house, she brought home a brown paper envelope she had found on a train. In it were some legal papers which related to a celebrity (one we didn’t like much). There was nothing deeply personal in them but it was an interesting bit of gossip, so I suggested she ring a couple of newspapers and one of them bought the story and ran it the next day. It paid for our patio. I suspect if the traveller got anything for the papers they found it was more than the price of a few dozen paving slabs.

Just through on my News feed, is the story that "A personal computer holding sensitive documents relating to defence and extremism has been stolen from Hazel Blears’ constituency office in Salford." I say the same thing to customers over and over again. Computers get lost, they get stolen. Vista makes it easy with Bitlocker. If Vista isn’t your plans, then do it with something else. If you don’t use full volume protection and you have "secret" data on them you know what is coming. Interestingly whilst this story of a stolen laptop made the news it has a totally different tone because it was encrypted.  It sounds like Hazel Blears’ PC was not.

According to the BBC. "The machine contained a combination of constituency and government information which should not have been held on it.". Oh deary, deary me.  I’m not going to venture in opinions of Hazel Blears… except to say I would laugh – a lot -  if the "documents on defence and extremism" led to of her facing court for possessing "a record of information of a kind likely to be useful to a person committing or preparing an act of terrorism". Sadly the Police only have 28 days to hold her while they find out if a charge can be brought.

If I were Hazel I’d stay out of the boss’s way for a bit. He was saying only at lunch time that we really didn’t need principles like habeas corpus any more and we could trust the government with an ID cards database, Facial recognition CCTV, Automated Number Plate cameras, a DNA database etc etc. … a state of affairs which a colleague who grew up in the old East Germany called "Beyond the dreams of the Stasi".  No party politics here: no government can be trusted with that data, whether the person in charge is named Erich, Gordon, or Dave.

This post originally appeared on my technet blog.

Tech Registrations open…

Filed under: Events,Windows Server — jamesone111 @ 11:21 am

Last week we ran our Tech-ed event for the US, and we have just opened registrations for Tech-Ed for Europe, Middle East and Africa (EMEA). Various other parts of the world have their own Tech-Ed events (I’m jealous of Eileen getting to go to one in New Zealand.)  These are our premier technical education conferences.

Tech-ed provides FIVE days of technical training:  we have two events running back to back in November; and we’re back in Barcelona. TechEd IT Professionals 2008, 3-7 November and TechEd IT Developers 2008, 10-14 November, Barcelona, Spain , this year they are using the tag-line ‘Learn, Connect, Explore’ – not surprising for events which provide deep dive technical training, information and community resources.

And as in previous years we have some discounts for booking early. (And a word of warning, last year the IT-pro event sold out before the end of the Early bird pricing, so if you do things at the last minute you probably won’t get a place … that is probably the strongest recommendation there is)

  • Book by 31 July 2008: Super Early Bird:
    €1,945 +16% VAT – €300 off the full conference price plus you get Preferential rate hotel accommodation, not to mention a Cap and Priority Seating in the Keynote sessions.
  • Book by 26 September 2008: Early Bird Deadline
    €1,945 +16% VAT – the same  €300 off the full conference price – but without the other benefits.
  • After 26th September
    €2,245 + 16% VAT

 

 

This post originally appeared on my technet blog.

June 16, 2008

How I get the server 2008 I want: #3: Vista look and feel

Filed under: How to,Windows Server,Windows Server 2008,Windows Vista — jamesone111 @ 2:19 pm

Server-glass I’ll be the first to admit that Servers don’t need to have the nice look and feel that we get with Desktop Operating Systems. But since the core of the OS is common to both it is possible. In Windows Server 2003 we had the XP Themes Service and if you switched it on you got something similar to the XP look.

In Server 2008 we have a couple of things more things to do.

1. Wireless. If you are using Server 2008 on a laptop for Demo or Development purposes you probably have wireless, but it doesn’t work… Until you add the Wireless feature, and turn on the Wireless service

2. Sound. The sound services are set to start manually. I set the Windows Audio service to Automatic start , and when it starts, it also starts the Windows audio endpoint builder.

3. Vista Applications (media player, mail calendar etc) , Glass, Explorer styles and so on come in the Desktop Experience Feature. This seems to need a reboot to be fully functional but when it is you can go to services and turn on the Themes service , then from personalization select the Vista Theme.

I’ve found that Server 2008 matches vista for performance but it lacks a few features- so I’m not going to be switching to it full time. A quick run down of what I’d lose (whether these matter to you is another matter).

  • BlueTooth support (I’m told the Microsoft Presenter mouse works with its Bluetooth Dongle, but I can’t connect my phone or GPS puck)
  • No Sidebar. Whether you like side bar seems to depend on whether you’ve found gadgets you like. I have a couple but I could live without it.
  • Readyboost. Server does have superfetch but won’t use memory sticks to enhance performance
  • Sleep and Hibernate – actually server has these but they go away when Hyper-V is running.

This post originally appeared on my technet blog.

How I get the server I want: #2 Getting sound in Hyper-V

Filed under: How to,Virtualization,Windows Server,Windows Server 2008 — jamesone111 @ 12:13 pm

Before I start – lets be clear THERE IS NO SOUND CARD IN A HYPER-V VMimage

Good. Now that’s out of the way lets talk about how we get sound in a Machine without a sound card – and this applies to a physical server too.

Sitting in it’s rack in the data-centre there is no reason why a server should have a sound card, and not much need for it. When you run applications via terminal  services you might very well want sound and so the Remote Desktop client (MSTSC.EXE has an option "Bring Sound to this machine"

Although Hyper-V connection use the same RDP protocol under the surface, this behaves as though it is plugged into the VM’s graphics card, it’s not a "remote desktop" session, so to get this to work you need to have Remote Desktop (Or full on Terminal Services installed).

You need to start the Windows Audio Service on the remote server. If it’s not running when you log in you won’t get any sound in that session, so if you start it from remote desktop connection, save yourself some grief and log out.

RDP-Sound Once you’ve done that you can turn on the the volume control and you should see that a "pseudo" sound card is installed.

So now my demonstrations of Hyper-V include using Terminal Services Remote App in the Parent partition to run PowerPoint PowerPoint with sound from a Child VM.

This post originally appeared on my technet blog.

How I get the server I want: #1 Disabling the shutdown event tracker

Filed under: How to,Windows 2003 Server,Windows Server,Windows Server 2008 — jamesone111 @ 8:21 am

shutdown2 I think that the shutdown event tracker came in in Server 2003, and I’m sure that in some data centres it is a very useful tool for logging why servers were manually shut down.

On a demo system, it tends to be a nuisance. Hyper-v, for example, disables Sleep and hibernate so if you have it on a laptop you have to shutdown if you’re going to be on the move for any length of time. If you’re asked Why ? every time it grates pretty quickly.

Some time ago I found how to disable it, and I was setting up a new build in the office a few days ago when a passing colleague said  "I never knew how to do that… you should blog it".

It’s simple enough, you can control it through group policy if the machine is a domain, or via the local group policy object. In the latter case start the MMC and load the Group policy Snap-In and point it to the Local Computer.

Once you can see the network or local policy , navigate to Computer Configuration, then to Administrative templates, then to System. In the system container there are a number of sub-containers, scroll down past those and you’ll find some settings, you’re looking for "Display Shutdown Event Tracker". You can set it to Enabled, and display Always, on workstations only, or on Servers Only. Or you can set it to disabled. If the setting is not present it seems to be enabled/Servers Only by default.

Click for full size image

Once it is disabled. the dialog disappears . Job done. 

This post originally appeared on my technet blog.

How to get PowerShell snapins to work on 64 bit

Filed under: How to,Powershell — jamesone111 @ 12:05 am

I mentioned a problem with 64bit Powershell in my previous post: 3 snap-ins I’ve wanted to use have been packed for 32 bit and didn’t work "out of the box" on 64 bit, so  I thought I’d give a generic guide to making snapins work on 64bit.

  • Install the the Snapin using what
  • ever tools the writer gave you, Under the hood this will invoke
    C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe "<PathToDll>"
  • Start Powershell AS ADMINISTRATOR and use the command
    Get-PSSnapin -Registered | fl name, modulename
  • If you don’t see your new snap in on 64 bit run the command
    C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "<PathToDll>"
    Things to note. First. This will fail if you don’t have admin powers, Second if you don’t know the path to the DLL use the same get-psSnapin command in the 32 bit version.
    After you have got success messages from installUtil , for a second time run
    Get-PSSnapin -Registered
  • Be aware that the name you get when you run the command in 32 bit may not be same in 64 bit. I found this trying the Windows Mobile Provider from Codeplex It’s called "PSMobile" in 32 bit and "Nivot.PowerShell.WindowsMobile" in 64 bit . The PowerShell Community Extensions use the same name – PSCX – on both.
  • Load the Snapin with 
    Add-PsSnapin "<SnapInName>"

I got an error that the WindowsMobile provider could not find  WindowsMobile.formats.ps1xml in the FormatData folder , so I made the folder and copied the file into it. I think the set-up configures one folder and the command line assumes another.

This post originally appeared on my technet blog.

June 15, 2008

Open-XML. This is what it’s all about.

Filed under: How to,Office,Powershell — jamesone111 @ 11:46 pm

I have been saying for ages that most IT professionals really don’t give two hoots about Open-XML. It’s a file format. Who cares ? My first chart - click for full size version

The old file format had been around for ages, and was pretty opaque, so hardly anyone dug into it. The new format is XML (which is good), and rich (also good), but complicated (not so good). It’s joined the ranks of formats approved by ISO, which might matter if to those Government trying to follow de-Jure standards (and ignoring de-facto ones… X400 vs SMTP anyone ?). But to IT Professionals in the commercial sector using and supporting office, does any of this matter ? Don’t they see file formats as "black boxes" … they might say that in theory it’s lovely that instead of something proprietary file internals are now XML (and standard’s body controlled XML)  but in practice they still need to deal with a change in file formats. Will they take advantage of the changes  ? And some will wonder if manipulation through the Office Object model which we’ve been doing since word 6 wasn’t enough ?

Time to Reconsider. 

This week we released the Open-XML SDK. It allows developers to work much more quickly with Open-XML. That’s obviously a Good Thing because it will bring more things to market which can work with the format. Still to the kind of IT-Pro I’m thinking about … the kind who I think reads this blog … a new SDK isn’t exactly a reason to crack open the champagne. OK we can manipulate the files without having the applications present, and  developers who slave away in C# might produce stuff which IT pros want… but what can I do with this RIGHT NOW ?

How about charting your Data Centre Activity in Excel. I can almost feel the interest, but it’s tempered with a "but that needs a bucket full of code …. doesn’t it". At risk of repeating myself

Time to Reconsider. 

Eric White – a fellow evangelist, although I’ll confess not one I could pick in an ID parade – has posted some the C# code for a PowerShell snap-in to CodePlex. This shows there might be a bucketful of code, but you don’t have to be one who writes it.  You can view what’s on Codeplex as two things, one is a demo of what can be done with the Open-XML SDK. The other is a bunch of Powershell cmdlets which are useful in their own right. Now those readers who have seen some of my PowerShell might still feel cautious – there may still be some nasties here.

Time to Reconsider. 

How’s this for a command line to get running processes into a spreadsheet.

   Get-Process | Export-OpenXMLSpreadSheet -OutputPath Process.xlsx  

That’s it. Not nasty is it ? Cynics might think "I could use Export-CSV and open that in Excel". But we’re just getting started. How about a graph ? These two lines of PowerShell get the total CPU time used by running processes, and then gets the 10 heaviest processes, and spits out their ProcessName  and %CPU – the proportion of CPU they’ve used (the method is a shade simplistic but bear with me)

   get-process | foreach -begin {$TotalCPU=0;} -process {$TotalCPU += $_.CPU;}   
Get-Process | sort -descending cpu | `
select -first 10 -property ProcessName, @{name="%CPU" ;expression={100*$_.cpu/$TotalCPU}}

You’ve already seen that we could pipe that into Export-OpenXMLSpreadSheet. But I want a bar chart of CPU used for each process, what would that need.  The video Eric has on his blog gives the answer – the extra switches needed by Export-OpenXMLSpreadSheet would be

   -chart -ChartType Bar -ColumnsToChart %CPU -HeaderColumn ProcessName

I thought I’d have a go, I had the Express version of C# on my demo server but no Office. I downloaded the SDK, and the Stuff from CodePlex, copied what I’d seen Eric do in the video and hey presto I had a compiled version set-up for 32 bit powershell only. This is not the first and won’t be the last Snap in to only register as 32 bit. Fortunately I know how to fix that and next post will explain it.  But within 30 minutes I’d produced the chart you see here, and opened it using office in a VM on the same box.

In my previous role as a consultant I would have loved tools like this. Giving the client reports that were easy to understand and looked great from Exchange , System Center Virtual Machine Manager, HPC, you name it… The PowerShell community extensions could even mail them as an attachment. .

Eric’s video shows how multiple documents can be given a common style and gives a bunch more detail. Seriously if you didn’t think you could learn anything from an 8 minute video today it might be time to reconsider.

 

This post originally appeared on my technet blog.

June 14, 2008

Doubts and Powershell, Hyper-V KeyValue pairs and Hash tables.

I’ve said a number of times that I think technical people are rarely secure in their own abilities; that they have a demon on their shoulder who whispers "You’re not really, that good" … "They’ll find you out one day". I was talking to a colleague this week who seems to be racked by such doubts, and saying that it’s better to the one who doubts yourself, than have everyone else doubt you (echos of Kipling there).

I do get the odd moment of doubt about what I’m doing with PowerShell and Hyper-V.  So it was just fantastic to get a mail this morning saying that some work I’d done was used in one of the top scoring sessions at Tech-ed in the US this week. Hyper-V and Virtual Machine manager were generating a lot of excitement among customers throughout the event you can get a flavour of why in this  5 minute  video from the keynote. I’m getting ready to release the library of Hyper-V bits on Codeplex. I’ve found one thing which has broken by changes made since the beta, but with the next build to come out being the release I’m hoping that there are no new changes required. reg-KVP

One  area I have been looking at recently is "Key value pair  exchange". One of the integration components passes these pairs between the Parent Partition and the Child Partitions. The data lives in the registry under HKLM\Software\Microsoft\VirtualMachine – data going from the child partition is under Auto and data going to it is under Guest\parameters. It allows a Guest OS to know the name of the computer hosting it what that computer calls the VM where it is running, and it allows the Host OS to know the OS and Fully Qualified domain name being used in the Guest. The data is only available when the VM is running. The "KVP Component" WMI object has a "Guest Intrinsic Exchange Items" property. Does it return something simple like "ProcessorArchitecture-9" ? No… It returns a rather nasty block of XML like this for each one.

<INSTANCE CLASSNAME="Msvm_KvpExchangeDataItem">   
  <PROPERTY NAME="Caption" PROPAGATED="true" TYPE="string"></PROPERTY>
  <PROPERTY NAME="Data" TYPE="string"><VALUE>9</VALUE></PROPERTY>
   <PROPERTY NAME="Description" PROPAGATED="true" TYPE="string"></PROPERTY>
  <PROPERTY NAME="ElementName" PROPAGATED="true" TYPE="string"></PROPERTY>
  <PROPERTY NAME="Name" TYPE="string"><VALUE>ProcessorArchitecture</VALUE></PROPERTY>
  <PROPERTY NAME="Source" TYPE="uint16"><VALUE>2</VALUE></PROPERTY>
</INSTANCE>

Fortunately I can get my data with just two long lines of PowerShell – for readability they are split over several lines, one gets the KVP component object and one processes the XML

$KVPComponent=(Get-WmiObject -Namespace root\virtualization `
-query "select * from Msvm_KvpExchangeComponent
where systemName = '$($vm.name)'") $KVPComponent.GuestIntrinsicExchangeItems |
forEach -begin { $KVPObj = New-Object -TypeName System.Object } ` -process {([xml]$_).SelectNodes("/INSTANCE/PROPERTY")  |
forEach -process {if ($_.name -eq "Name") {$propName=$_.value};
if  ($_.name -eq "Data") {$Propdata=$_.value} }
-end {Add-Member -inputObject $KvpObj -MemberType NoteProperty `
-Name $PropName -Value $PropData}}
-end {$KvpObj} 

 

This is the basis of a Get-VMKVP function, which I can use like this:

PS C:\Users\administrator\Documents\WindowsPowerShell> choose-vm | get-vmkvp 

ID VM Name             State
-- -------             -----
0 SEA-DC-01           Stopped
1 HPC DC,DNS and DHCP Running
2 JON WDS             Suspended
3 HPC Compute Node 2  Stopped
4 Core                Stopped
5 HPC Head Node       Stopped

Which one ?: 1

FullyQualifiedDomainName : CCS-DC.CCSTEST.COM
OSName                   : Windows Server (R) 2008 Standard
OSVersion                : 6.0.6001
CSDVersion               : Service Pack 1
OSMajorVersion           : 6
OSMinorVersion           : 0
OSBuildNumber            : 6001
OSPlatformId             : 2
ServicePackMajor         : 1
ServicePackMinor         : 0
SuiteMask                : 272
ProductType              : 2
ProcessorArchitecture    : 9

With the aid of the another WMI call – (Described on MSDN) I can ping the VM. If I store it’s FQDN in $VmFQDN the line is

Get-WmiObject -query "Select * from  Win32_PingStatus where Address='$VmFQDN' and ResolveAddressNames = True and recordRoute=1"

What I really wanted to do was to check the status code returned by the ping and the MSDN page gives me a list of codes. Now one could use a switch statement to output the right text for the code – in fact  Jeffrey Snover’s most recent blog post does exactly that. But I showed before that I can do the same thing with a hash table so I have

$PingStatusCode=@{0="Success" ; 11001="Buffer Too Small" ; 11002="Destination Net Unreachable" ;
                                    [quite a few more and finally]   11050="General Failure" }

and when the time comes to return the status information I can use

$PingStatusCode[[int]$_.statusCode]

I mentioned Jeffrey’s post,  I’d be tempted to turn his code form

$sku = $((gwmi win32_operatingsystem).OperatingSystemSKU) 
switch ($sku) 
{ etc } 

to  @{hash-table}[Value]  format.

Now the hash table is long, but I’m probably going to paste it into my code from MSDN and it is easier to change it to the format below than the format needed in a switch statement. The [index] construction isn’t the prettiest ever either.  And remember although this is typeset as 26 lines this is actually a single line to PowerShell 🙂

@{ 0 ="Undefined";

1 ="Ultimate Edition";
2 ="Home Basic Edition";
3 ="Home Basic Premium Edition";
4 ="Enterprise Edition";
5 ="Home Basic N Edition";
6 ="Business Edition";
7 ="Standard Server Edition";
8 ="Datacenter Server Edition";
9 ="Small Business Server Edition";
10 ="Enterprise Server Edition";
11 ="Starter Edition";
12 ="Datacenter Server Core Edition";
13 ="Standard Server Core Edition";
14 ="Enterprise Server Core Edition";
15 ="Enterprise Server Edition for Itanium-Based Systems";
16 ="Business N Edition";
17 ="Web Server Edition";
18 ="Cluster Server Edition";
19 ="Home Server Edition";
20 ="Storage Express Server Edition";
21 ="Storage Standard Server Edition";
22 ="Storage Workgroup Server Edition";
23 ="Storage Enterprise Server Edition";
24 ="Server For Small Business Edition";
25 ="Small Business Server Premium Edition"}[[int]((gwmi win32_operatingsystem).OperatingSystemSKU)]

Hmm, From Self-doubt to thinking I can do PowerShell better than Jeffrey in one post… life’s been a bit like that recently.

Technorati Tags:

This post originally appeared on my technet blog.

June 3, 2008

Surprise of the day. In praise of Roadchef.

Filed under: Mobility — jamesone111 @ 3:49 pm

A few days ago I posted in praise of McDonalds for their free WiFi. So I shouldn’t have been surprised to stop at the motorway services and find Roadchef (at least at Norton Canes , off the M6 Toll) are doing the same. But in an otherwise predictable day, it was a surprise.

OK they did charge me £7.35 for a sandwich and a cup of coffee so one can argue they can afford it: still if places like this are giving free access (and to be fair , without requiring a purchase) it just adds to the pressure on places like hotels to stop stinging customers for access.

This post originally appeared on my technet blog.

Blog at WordPress.com.