Welcome to TechNet Blogs Sign in | Join | Help

Road-show materials.

I’ve had a couple of requests for the slides and related information from the”Unplugged” tour

My Keynote slides

My Hyper-v Cluster setup and Jose Barreto's blog post on getting Storage server for iSCSI 

Matt’s slides on Management and SCVMM (these are in a Password protected zip, the Password is Password 123)

Clive’s Slides on Management and SCVMM

My slides on Terminal Services

 

I’ve given the link to Jose’s post for iSCSI in the list above, but there are other iSCSI solutions – I normally mention Nimbus but I forgot to mention it in Monday’s session. Thanks to Dave for the reminder.

Get Safe Online ‘08

The First time I ever worked with Steve was on GSOL the first year it ran. It’s become an annual event, and I hope that no-one who regularly reads this blog needs to be told too much about on-line safety. It’s pretty simple stuff.

  • Keep your machine patched
  • Use Anti-virus Software
  • Use a firewall
  • Be careful what you click on.

The BBC had a story that Spammers only get one response for every 12 Million mails … and as part of GSOL we have a poster up with the top 5 email scams

  1. Fake lottery wins
  2. Fake requests for payment details
  3. Updating On-line service details
  4. Notice of an inheritance
  5. Foreign aid / Charity payments

The BBC had another story about IDs being sold.

So, do your bit and spread the message to those less IT savvy than yourself. Don’t scare the life out of them, just make them aware of what a scam looks like. You know you didn’t even enter the lottery that mail says you’ve won, and you know if you gave your mail address to a lottery. You know that your bank would address you by name and tell you to go to their main site and follow a setup of step if they really needed you to do something and so on. That kind of thing, and send them to http://getsafeonline.org 

By the way… I think a lot of things are said to be in the name of “protecting children” are actually humbug, but I heard a good story at tech.ed in Barcelona that one security person got his young son to create a fake on-line persona – he was a 70 year old man with a wooden leg, or something like that. “So Dad …” the son asked “does that mean other people on the internet aren’t who they seem to be ?” . Far more effective than “Don’t talk to Strangers” which is what I grew up with.

Posted by jamesone | 0 Comments

Server 2008 R2 – Server Core changes.

As I said in my last post I have a whole stack of things to talk about in the aftermath of Tech.ed in Barcelona. One of those is the changes made in server core.

Fortunately Andrew over at the Windows Server Core blog has saved me a job, his post has more detail,  but the major change is a subset of .NET framework for core. This allows two really important things. PowerShell 2 and ASP.NET. Today Server core has no .NET framework support so that means ASP or plain HTML pages, but no ASP.NET.  ASP.NET is a obviously a step forward because you shouldn’t really have to care if a web server is on Core or on Full Windows when you decide what it will serve up. But PowerShell ? I keep telling people that you manage Windows Server Core remotely. You don’t logon to the console and fire up PowerShell….but with PowerShell 2 we have much richer remoting, and remotely managing a machine with PowerShell means you run the shell on Machine A and specify that you want to run a command on Machine B.

We also have File Server Resource Manager support, and the ability to add Certificate Services. Finally. Server 2008 R2 is 64 bit only, support 32 bit application will be available but the plan is that you will have to choose to install it, to keep the footprint as small as possible.

 

Back from tech.ed

I’ve had a busy few days: after Tech.ed we had some internal training in Barcelona over the weekend, and I  flew back from Tech-ed to a concert in London on Sunday night. I have quoted a line or two of Anne Clark’s on this blog: I saw her in a TV programme about a book called “Hard lines”, and they said she had a Album out. That was 1983 (or possibly 1982), and I’ve got just about everything she’s done since; but she hasn’t played in Britain for years and its taken me a quarter of century to see her live. Just brilliant. But I didn’t get home till 1AM.

Tech.ed seemed better than last year – at least to me, and I’ve got a long pipeline of posts about Windows 7 which will follow this one. My one complaint is that the shirts we given as speakers were cheap polyester ones and I’ve had some kind of skin reaction to them. When I got home It was a quick change of clothes in my bag and then jumping on a flight to Edinburgh for a virtualization event there. I forgot to take the anti-histamine cream with me, and so was itching like mad on stage for the day. Not good. Back south for a a quick team meeting and then off again for another presentation in London, home, re-pack and then I’m in Cambridge tonight, and presenting there in the morning. 

I have a ton of posts to write on Virtualization, PowerShell and some of the more interesting stuff about Windows 7/ Server 2008 R2 which now public and some other writing to finish which I’ll talk about here when it’s done.

The flight to Barcelona clashed with Brazilian grand prix, and I’m carrying the Media center recording of it with me, hoping to get a chance to see it in a hotel somewhere soon. I called home as soon as the ‘plane landed and got the news from my 8 year-old daughter (one of the world’s most passionate Hamilton fans) that Hamilton had won the championship, and it hinged on passing Timo Glock (though it was the following morning that I found out what a close run thing it had been). Because I’ve talked about F1 and some of the nonsense which has come from the people who run the sport on this blog, a lot of people at tech.ed started conversations with me about F1 and the race. One person has even mailed me to say he was looking forward to reading my take on how things finished and was bit disappointed not to have seen it yet. So… in the end justice was done. Massa benefitted from some very iffy Stewarding decisions (Hamilton’s penalty in Belgium, giving him a win and 6 point benefit, his own lack of penalty for a dangerous pit release in Valencia letting him keep a win which would have gone to Hamilton, and giving him extra 4 points, and not Penalizing him for going off the permitted track to overtake Webber in Japan giving him 2 more points, which only have been one had Vettel not received another dubious Penalty). Had Massa won people would have been saying for years that he shouldn’t have been champion (they would have ignored the fact those points were cancelled out by the teams error in Singapore which cost him a win and gave Hamilton an extra point).  On the other hand Ferrari – who always seem to be the beneficiary of these decisions – won the constructors’ championship. Reverse out the bad decisions and Hamilton would have won the drivers’ title by more (and had 7 wins to 4  for  Massa), and Ferrari would have had won the constructors by less, but the result would have been the same – the gap between the second driver in each team was greatly in Ferrari’s favour.

My worry now is that Hamilton will become as dominant as Michael Schumacher was and we’ll be in for seasons of very dull racing. From a purely sporting perspective the Senna’s untimely death meant we never had the spectacle of the rising Schumacher taking on the Senna as “old master”. Schumacher’s retirement means we don’t see him race Hamilton, and I don’t see him being temped back. But against that fear is the hope that with Vettel, Kubica and Alonso (who scored more points than anyone over the last 8 races) as well as the two Ferrari and two Mclaren drivers winning races this year we could be at the start of a new Golden age. I remember the days when Mansell, Piquet, Senna, and Prost were competing – hopefully there will be enough good cars to go round, and any one from half a dozen drivers and 3 or four teams could win. I’ve been a Williams fan since for even longer than I’ve been an Anne Clark fan, and Keke Rosberg was one of my favourite drivers. Two sons of great drivers have won championships in Williams’  cars. I still hold out hope that for a third.

Since I’ve been anti-Ferrari for decades (they were getting the benefit of bad decisions when James Hunt raced for Mclaren, and against Williams in the 80s and 90s) I should make my last planned comment on Motor racing for this year an acknowledgement that they can do something good – the FIA’s idea of all the teams using standard engines has to rank as one of the worst I’ve ever heard. Ferrari took a stand against it and helped drive down the cost of engines for non-works teams. Near identical cars which are the limiting factor – rather than driver skill -  is what has made American single seat racing so boring. So a tip of hat to the team in red for killing that idea.

And now, back to that large pile of posts …

Posted by jamesone | 2 Comments
Filed under:

Slides and scripts from Open XML / PowerShell reporting Session in Barcelona

I'm going to spend the next two or three Posts explaining what I did in this session for those who weren't there but, for those who were I promised the slides and scripts would be downloadable

You can get the zip from my skydrive

Posted by jamesone | 2 Comments

Virtualization videos

I mentioned I was presenting on Virtualization a week or so ago, and Matt was presenting another of the sessions. Without wanting to make a big deal of it, but since I’ve got to know Matt, I’ve come to value his opinion and he used my library from codeplex. to  demo building VMs from a script, he had some really nice things to say about, which did my ego a power of good. 

John Kelbley is a chap I know less well, but it’s always nice to have people who work in the product team telling you that you’ve done a great job. John pinged me a mail to say his discussion from the US tech-ed with Alexander Lash about script-based management for Hyper-V, including a discussion of PowerShell and WMI where they use my library was posted. It’s available for download.
WMV High res version
WMV Low Res version
MP4 Version
MP3 Version

I’m going to be recording at least one video session on PowerShell at Tech-ed Barcelona this week, and with a bit of luck we’ll get one together on Virtualization as well.

Bonus Link, before my ego gets out of control, thanks to Matt for the link to a great Silverlight demo of System Center Virtual Machine Manager.

Internet connections and People ready businesses

I’ve been “on Holiday” for a few days. My mother-in-law hasn’t been enjoying the best of health so we took took the family off to visit her over the half term week. To a rented house with Satellite TV – because it is in a DVB deadspot – but no broadband, and no 3G reception. It’s been a lesson in just how much we take connectivity for granted.

The 3G part was interesting: Microsoft provides me with a phone  its due for replacement in a few months (hopefully with one of these), for me the candy bar form factor with slide out qwerty keyboard is perfect, and when I got my current one the only 3G option was a touch screen PDA. I’ve shut up about the iPhone, it doesn’t work for me nor do the Windows-powered touch screen phones. They work for lots of other people. Fine: we’re not all the same.  So I went shopping for a Pay as You go 3G service in Oxford – where half the shops now seem to be phone shops or coffee shops. I asked each provider to check my destination was covered, all of them could check, and had to admit it wasn’t To be fair, Orange’s web site suggest they have coverage but that they don’t offer Pay As You Go 3G. I wanted to check both things, but their Oxford shop was being refurbished, so I thought I’d go to a mobile phone shop when we arrived.  Reading this piece on Mark's blog I realise that this will soon be considered suspicious (The Times reports Everyone who buys a mobile telephone will be forced to register their identity on a national database under government plans to extend massively the powers of state surveillance.) . I like the fact that my phone isn’t registered to me: if it was at a crime scene it could be traced to me in 5 minutes flat. The same is true of my (leased) car.With no way to look up my phone or my car, its hard for someone to go on a fishing trip about me. I’m nervous that a computer somewhere in the Home Office would spot my purchase of a 3G dongle far from home and send someone to check things out. As it happens, there was nowhere to buy one anyway; this is a town with no mobile phone shops, no McDonalds with free WiFi, no Starbucks. A single Cafe had internet access – at 5p a minute! Once the home secretary catches up with the notion of VoIP, I guess we’ll have to produce Biometric ID to use cyber-cafes. 

A fair chunk of my expensive internet time was spent arranging my hotel for Tech-ed – I don’t know why I left it so late; usually when I start procrastinating about everything it is a sign something is wrong. The travel coordinator gave me the necessary URL  but my chosen credit card issuer doesn’t participate in the site’s chosen verification scheme. So I mailed the coordinator back, explaining that I’m on holiday, I don’t have proper access, the web site won’t play ball, so here’s my credit card number, please book the room. Back comes a reply “we need a fax for security reasons”.  I reply “You want something with a signature on it … even though you can’t tell if it is really MY signature, that’s no security”. And who takes a fax and printer on Holiday ? Somewhat crossly I went back the next day to try another credit card, this takes me to “Verified by visa”, or “vilified by Visa” because I couldn’t get it to accept my details. What followed was actually rather wonderful. My phone rang, it was the bank’s fraud department, a  computer somewhere had spotted my failed purchase far from home and sent someone to check things out. With the transaction cleared the call got passed to someone in a totally different part of the bank, who knew what was going on, and walked me through the Visa system and hey presto everything worked. I’ve no idea what software they  use at first direct but when we ran commercials about “The people ready business” we meant the sort of thing they have been doing for years. And the Hotel bookers were the target to become people ready. [Side point. I have long had a theory that people get more choosey about where they place their business when the economy is bad “lots of you are chasing my custom, so I’ll go somewhere that I don’t have to put up with X.”. If you’re an IT pro and your projects don’t lead to delivering something better to a customer, what exactly are you doing ?]. 

On the subject of my procrastination leading to find out of companies are people ready or not, I nearly gave this post a risqué title like “Sucking big Julie dry” as I explained a couple of weekends back , “Big Julie” was the identity I floated for my new car from its registration “Sierra Juliet”, though that name just isn’t right. The last 4 Citroëns I’ve had were equipped with a trip computer showing range at about 20 miles the display would change to --- meaning “I can’t guess any more. Fill up right now”. I try to avoid filling up until I absolutely have to, so I quite familiar with that display. With  Trip computer still indicating 22 miles range and a mile from where I planned to fill up something horrible happened. The engine stopped. I expect embedded computers and their sensors to be 100% reliable – which means if they are wrong they fail in the direction of safety. I wouldn’t accept my latop’s battery dying when the display said 10 minutes left: tell me I’m out of fuel with 20 miles left – not the other way round.
I called Citroën assist – “We can get someone to you in about an hour with some fuel” they said, “I can walk and get some in less time” I said “but does the engine need to be re-primed ?”. “No” said the guy at the other end. “Are you sure there’s no special procedure for a dry diesel engine” “Yes”. “OK I’ll walk”. 45 minutes later with 5 litres of diesel in the tank I was back on the phone - “The engine won’t start, the handbook doesn’t cover this engine, only the V6 diesel and there’s nothing about re-priming that”. “OK. We’ll send someone out – it will be about an hour”. Grrr. If I’d known, I’d have got them to send him in the first place. We called a taxi so the rest of the family could get home and I waited. I got a call and a text from the AA (that’s the Automobile Association, if you’re thinking of something else known as AA)to say they were on their way. Now here’s a tip. If you have a Peugeot or Citroën with a 2.2HDI engine (and according to Wikipedia possibly a Ford with the 2.2  TDCi as well)  and you run it dry, open the bonnet and look for a little black bulb with a fuel line coming from it, on the left near the front. The AA man squeezed that a few times, I turned the key and hey presto the engine sprang to life.  One of his easier jobs. On the one hand calling a number and having someone sort the problem out is great, but the computer at Citroën assist knew what model and colour my car is… so why didn’t it give that tip to the person on the phone ? It just didn’t come up to scratch on people –readiness.

 

Bonus link, Given where I was this story from Jason had me almost crying with laughter

Posted by jamesone | 0 Comments

High Performance computing Webcasts over the next two weeks

I haven’t really said much about Windows HPC server 2008, which we launched recently as the successor to Compute Cluster Server. But there are some useful webcasts lined up , they’re early in the morning Redmond time, which puts them at then end of working day for those of us in Europe.

HPC Webcast Series: High Performance Computing for the Masses with Intel

November 4, 2008, 9:00am PDT

High Performance Computing has its roots in non-commercial, academic, national lab and governmental environments where very large, compute-intensive workloads and applications are executed.  According to recent data from IDC HPC, economically-attractive clusters have become the common denominator across most HPC deployments.  In parallel, the continuing maturation of HPC ISV commercial business software, the refinement of operating system & cluster software, and the consistent availability of more computing power at lower cost have opened up the inherent performance advantages of HPC clusters to a much wider community of users.  Please join Intel for an overview of the current HPC marketplace and the potential alternatives of utilizing High Performance Computing clusters for both increased productivity and competitive advantage. Register today!


Dramatic Acceleration of Excel-based Trading Simulations with Platform and Microsoft

November 5, 2008, 8:00am PDT

Tired of waiting hours for simulation results? In this solution overview, Platform will review the challenges of running Excel models in a distributed environment, and describe the benefits and details of how to deploy models without wholesale code/macro changes. Learn how to enhance application performance and empower quants and developers to deploy distributed applications quickly without modification, using Platform Symphony's Excel Connector with Windows HPC Server 2008 and Microsoft® Office 2007 Excel. You’ll discover how the world’s top financial firms can realize new revenue opportunities ahead of the competition by leveraging this joint solution. Register today!


High Performance Computing (HPC) Clusters: Reduce Complexity with IBM and Microsoft

November 6, 2008, 8:00am PDT

No matter where you are located in the world, IBM has an HPC cluster solution that is easy to deploy.  Learn how IBM can help you reduce the risk and manage growth more easily with the pre-tested, easy-to-deply, easy-to-manage IBM Cluster 1350 solution, and how when combined with Windows HPC Server 2008 you can leverage your current Windows server expertise to accelerate your time to insight on computational analysis.  Whether you are a financial analyst or engineer our Windows based HPC cluster will meet the demand of your computational needs. Don’t miss this exciting and informative webcast. Register today


Improving Electronic System Design Productivity using Synopsys System Studio and Saber on Windows HPC Server 2008

November 12, 2008, 8:00am PDT

Synopsys System Studio and Saber products are now available on Windows HPC Server 2008.   Join us for this informative webcast and get the latest information on how System Studio further improves performance and signal processing design productivity by taking full advantage of Windows HPC Server 2008 as a stable, extensible environment on high-performance CPUs. Learn how Saber helps automotive and aerospace supply chains meet stringent reliability and safety requirements for mechatronic systems in harsh environments.

System Studio is Synopsys' model-based algorithm design and analysis offering providing a unique dataflow simulation engine with the highest performance for exploring, verifying and optimizing digital signal processing algorithms. Saber is Synopsys' technology-leading mechatronic design and analysis software, advancing Robust Design and Design for Six Sigma (DFSS) methodologies into today's automotive, aerospace, and commercial design. Register today!

Scheduling task on Server 2008 – a Hyper-V snapshot

I had a mail from Alessandro, asking about scheduling operations on Hyper-V; specifically he wanted to schedule the snapshotting of a virtual machine. The logic was already in my codeplex library, but it only needs a couple of the functions (new-vmsnapshot and get-vm), but the easiest thing seemed to be to make its own PS1 file and then create a scheduled job to run PowerShell with that command.

So here is the script which I saved in the Hyper-V program files folder as "New-VMSnapshot.ps1". It takes the name of a VM and optionally the name of a server and kicks off the snapshot.

Param( $VMName , $Server=".")

vm=Get-WmiObject -computername $Server -NameSpace "root\virtualization" `

-Query "Select * From MsVM_ComputerSystem Where ElementName Like '" +

$VMName + "' AND Caption Like 'Virtual%' "

if ($VM -is [System.Management.ManagementObject]) {

$arguments=($VM,$Null,$null)

$VSMgtSvc=Get-WmiObject -ComputerName $VM.__server -NameSpace "root\virtualization" `

-Class "MsVM_virtualSystemManagementService"

$result=$VSMgtSvc.psbase.invokeMethod("CreateVirtualSystemSnapshot",$arguments)}

Before explaining how to schedule the script, I should give a couple of warnings about snapshots: first, reverting a machine to a snapshot can break the connection to its domain because the password for the secure channel has changed since the snapshot was taken. In training, demo, or test environments you can shut everything down, make a consistent set of snapshots and apply them all. That's not an option for production environments.

Second, remember that a snapshot turns a VM's current disk into the parent half of a differencing disk, and if the VM is running saves its memory as well. You can use a lot of disk space by being over-eager with snapshots, and you will blunt system performance. Deleting snapshots merges the differencing disks (creating a temporary disk which uses even more space) but only when the machine is shut down. Restarting the VM before the merge is complete will abandon the operation. So if you schedule snapshots you should have a plan to remove them regularly.

Creating the scheduled task is easy on Server 2008 - it uses the same scheduling tools as Vista. go to the Task scheduler (either as a free-standing tool or in the server manage) right click the scheduler and choose add ask and click though the wizard. On the general page you need to make sure the task runs if no-one is logged on, the triggers page specifies when the task runs and the actions page specifies the command(s) ,

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe 

and arguments to be passed

"& 'C:\Program Files\Hyper-V\new-Vmsnapshot.ps1' 'core' "

So much easier than the old AT commands.

Mary Jo Foley and Windows pet peeves.

It was interesting listening to Mary Jo at the event Eileen got together last week. Mark has a good write up.

No two ways about, Mary Jo’s a PC:  there were a couple of comments she made which stayed with me one was that other companies  “can do things which Microsoft would get skewered for” and the other was that “Vista can’t seem to get a break.” Now I’ve been pretty open in my love of Vista since before it shipped. Mary Jo gets plenty of flak when she says anything positive about the product almost - entirely from people who have never used it. one of her pet peeves seems to be people who say “My apps don’t work” but when she asks which apps she never gets a response.

My pet peeves are “Vista is unreliable” and “Vista takes a long time to boot”. My answer to the slow boot is “why do you keep rebooting”. The only faintly reasonable answer I ever get to this is “To save electricity”. That conveys a misunderstanding of hibernate: hibernate powers the machine down stone cold, but it doesn’t require the OS to go through all the hoops of reloading from scratch. Even that way of working doesn’t stack up. The numbers usually quoted are 5W in sleep and 125W Powered up. So, go from a world where a machine never sleeps – it is either running or shut down, to one where it does sleep… I did some rough sums and found my machine runs about 80 hours a week (I use my laptop at home in the evening and weekends, and not exclusively for work) for simplicity I’ll say it sleeps all of the other  88 and never hibernates.  That’s 10 KWh for time the machine is running and 0.4KWh while it is sleeping. Put in perspective 1KWh of electricity from the UK grid creates 0.54Kg of CO2, so sleep creates 200g of C02 a week. The same as driving the average car 1KM, I could save that by parking at the entrance end of the Microsoft car park and walking to my building.

Still, it looks wasting 4% of my power consumption by using sleep instead of hibernate. BUT, sleep lets my machine cat-nap while I’m not using it. Do those cat naps save the 3.2 hours of full power running that would burn the same 0.4 KWh ? Absolutely. It probably saves it on a Saturday, and again on a Sunday, and a 3rd time during the working week.

I listen to people talking about the green priorities of their organization, but when ever I ask them what they are doing to get their desktop PCs to stop running screen savers for 100 hours a week I never get a proper answer.

As for unreliable, I have more reboots on my laptop because the battery occasionally bounces off when it is being lugged about in sleep mode than any other cause. The average is 6 days and 70 hours running between boots, but looking back over the stats two weeks between boots seems pretty standard. My home computer fares better. Since I put Vista on it back in June it has had one reboot which wasn’t down to applying regular patches (unplugging the TV tuner caused media center to get in such a twist I decided to reboot rather than fix it). That machine has a life which is much closer to that of a typical office machine. Unreliable ? PAH !

Posted by jamesone | 4 Comments
Filed under: ,

Tech-ed for IT professionals next week

Just a quick note to say that I will be spending next week in Barcelona. Anyone who is going who wants to meet up, feel free to mail me.

Posted by jamesone | 0 Comments
Filed under:

Virtualize or Virtualise ?

I was presenting at a session on Virtualization on Friday, and the Organizer had collated all the slides together into one deck. And he had “corrected” my spelling of Virtualization because one of the other presenters used Virtualisation with an S. Every so often people tell me that using Z is a nasty modern American innovation. In fact it is not. I worry when I’ve told people that it comes over as “You bloody idiot, don’t you know your own language”. (One of the check boxes in the on-line survey I mentioned a couple of Saturdays back was was “Other people frequently tell me that what I've said is impolite, even though I think it is polite.” that was one I ticked. And I’ve had a couple of reminders of it recently ….). So I don’t know if it’s bludgeoning the point home to trot out this quote from "Plain Words", by Sir Ernest Gowers, published by HMSO, but I find it useful.

On the Question of whether words like Organise or Organisation should be spelt with an s or a z, authorities differ. There are some words (e.g Advertise, comprise, despise, advise, exercise and surmise) which are never spelled with a z. There are others (such as Organize) for which the spelling with z is the only American form , and is also a very common British one. This being so the British writer has the advantage over the American in that we may, if we wish, use an s all the time, for that will never be wrong, whereas a Z sometimes will be. But do not condemn those who use z in it's right place.

I tend to use z because I learnt years ago that Organize was correct, and Organise was a Victorian affectation – as with some other bits of the language the Americans have stayed with the old way. Fans of my local fictional detective Chief Inspector Morse, might remember an episode which turned on a fake suicide note – the give-away was that the Oxford don supposed to have written it would never have used an S. Shakespeare would have called the letter “Zee” not “Zed”. What does bug me sometimes is when people can’t decide which to use. Because the little map on the right of my blog tells me I have a lot of non-British readers I tend to use the more international version, rather than trying to please those British readers who think Z is wrong, but provided a document for a British audience is consistent then I really don’t mind. I get more bother by data centre. At some point after the pilgrim fathers sailed British English decided to spell a number of words like that with a French-style –re, where the colonists remained true to –er. So our customers have Data centres (places, British spelling) in which they run Windows Server 2008 Datacenter edition (product name, American spelling), in which they say they Virtualise workloads (quoted text of an English author) using Microsoft Virtualization. (Product name).

Posted by jamesone | 4 Comments
Filed under:

PowerShell and Windows Media Player, part 2

In the previous post on this topic I showed how to get a media player object
$wmp = New-object  –COM WMPlayer.OCX

And introduced functions which worked with its playListCollection, mediaCollection and CurrentPlaylist to implement

Get-Playlist   
Set-Playlist
Get-media Get-mediaByAttribute
Get-MediaInPlaylist 
Append-Media
Reset-media

At the end of that piece I introduced

Stop-media 
Pause-media
Play-media

Which use the Controls collection of the media object.  There were 3 other functions which used the controls collection of the Windows Media Player object.

Function Select-nextmedia  {$wmp.controls.Next() } 

Function Select-Previousmedia {$wmp.controls.Next() }

Function Resume-media   {$wmp.controls.play() }

In fact start media was more complicated because I said in my introduction I wanted to set things up so that media would finish at a pre-ordained time, which meant figuring out how long a play list would take to play

filter Get-PlaylistDuration 

{param ($Playlist) if ($playlist -eq $null) {$Playlist = $_}
(Get-Mediainplaylist $PlayList | measure-object -sum duration).sum $playlist = $null
}

Although you can get the duration without looking at the detailed attributes for each item I wanted to get those too, in an object form which can be used in format-table and the like.

Filter Get-MediaDetails
{param($mediaItem) if ($mediaItem -eq $null) {$mediaItem=$_}
0..($mediaItem.attributeCount -1) |
   foreach -begin {$MediaObj = New-Object -TypeName System.Object } ` -process {$attributeName=$mediaItem.GetattributeName($_) if ($mediaItem.GetitemInfo($attributeName)) {
Add-Member -inputObject $mediaObj -MemberType NoteProperty `
-Name $AttributeName -Value $mediaItem.GetitemInfo($attributeName)}}
-end {$MediaObj}}

I wanted to wait until a particular song was playing and do something or wait till a particular point in the song, or just a particular time.  So that meant 3 more functions

Function Wait-Medianame 

{Param($name)
$Waiting=$true
while ($waiting) {
   start-sleep -seconds 1    Write-Progress -Activity $wmp.currentMedia.Name -Status "Waiting for song name to match $name"    $waiting= ($wmp.currentMedia.name  -notlike $name) } }

Function wait-mediaoffset
{Param($seconds)
$Waiting=$true
while ($waiting) {
   start-sleep -seconds 1    Write-Progress -Activity $wmp.currentMedia.Name -Status "Waiting until $seconds - position now : $($wmp.controls.currentPositionString)"    $waiting= ($wmp.controls.currentPosition -lt $seconds) } }

Function wait-until
{Param([dateTime]$EndTime)
$TotalTime=($endTime - (Get-date)).totalSeconds
$Waiting=$TotalTime -gt 0
while ($waiting) {
   Write-Progress -Activity ("Counting down to " + (get-Date).toString("t") ) -Status "Waiting" `
-percentcomplete (100 * ((($endTime - (Get-date)).totalSeconds / $totalTime)))
   Start-sleep -seconds 1
   $waiting= ($endtime.compareto((get-date))  -gt 0 ) }
}

With those in place I could go back to Start-Media and tell it I wanted the music to stop at a particular time, and knowing how long the playlist would play for I could tell it to wait for a particular time. I quite like the way that write progress is setup  so the progress bar retreats to 0 in wait-until

Function Start-media 

{Param ($EndAt)
if ($endAt) {wait-until ([dateTime]$EndAt).addSeconds(-1 * (get-PlayListDuration))}
$wmp.controls.play()
}

The only thing left on the music side was to set the volume level, first the simple way, then the a fade up or down. 

Function Set-MediaVolume {Param ($volume); $wmp.settings.volume = $volume} 

function Fade-Media 

{param ($level, $seconds) $steps = ($level - $wmp.settings.volume) if ($steps -gt 0) {   $interval = 1000 * $seconds / $Steps    for(;$wmp.settings.volume -lt $level;$wmp.settings.volume ++) { Write-Progress -Activity $wmp.currentMedia.Name -Status "Fading in " `
   -PercentComplete (100 * (1 -  ($level - $wmp.settings.volume )/$Steps)) start-Sleep -milliseconds $interval} } if ($steps -lt 0) { $interval = -1000 * $seconds / $Steps    for(;$wmp.settings.volume -gt $level;$wmp.settings.volume –) {
Write-Progress -Activity $wmp.currentMedia.Name -Status "Fading Out" 
-PercentComplete (100 *  ($level - $wmp.settings.volume) / $steps ) start-Sleep -milliseconds $interval} }
}

That took care of just about everything – except that for video it is necessary to launch a full media player window instead of just using the object. Fortunately that is a method on the main object so that got coded up as well. Job done. 

Filter Launch-media

{Param ($file);
if ($File -eq $null) {$file=$_}
   if   ($File -is [string])  {$wmp.openplayer($file) }
   else {$wmp.openplayer($file.sourceURL) }
}

 

Posted by jamesone | 0 Comments

SCVMM 2008 released.

There’s Billy Connolly sample which I’ve had on my PC for ages. To use it recently at Virtualization events Steve Lamb had to edit 3 rude works out of 12 seconds.

We want this, and that,
We demand a share in
that and most of that.
Some of
this and **** all of that
Less of that and more of this and **** plenty of this.

And another thing. I want it now.
I want it yesterday, and I want more tomorrow.
And the demands will all be changed then so ***** stay awake

Now…  if I worked on the Virtual Machine Manager team, that might be how I viewed the demands of the rest of the company…. I’d love to have been a fly on the wall when they were setting out their plans in 2006/7

  • We need you to write something to manage VMs. And we need it … soon as you can really.
  • You need to support Virtual Server because that’s shipping today.
    The API for Hyper-V is totally different and you’ll need to support that when it ships…. so better plan for a V2
    Oh … could you make it extensible and think about adding VMware support while you’re at it.
  • Physical to Virtual Migration is a nasty problem: go back and look at that one would you ?
    While you’re looking at that see if you can translate a VMware disk to a Microsoft one.
  • Setting up VMs from a library on the best suited host them isn’t straight forward either, so see what you can do..
  • Letting users access create and access VMs via a web portal would be ideal
    Hyper-V doesn’t expose the access control for VMs so if you;ll need to sort that out first
  • You’d better make it scriptable. No messing about, it needs to be done with PowerShell
  • We think High Availability will be big so make sure you can hook into cluster technologies.
  • These VM files are kinda huge so see if you can find a way of copying them in inside a SAN.
  • You need to fit it into the System Center family,
    in fact it would be great idea if you could make suggestions based on what the rest of system center sees .
  • Oh and Hyper-V is going to ship about 6 months after longhorn server, and there will be a Longhorn Server R2 about 18 months after that
    Go see the Hyper-V guys and see what they have up their sleeves for that one and start planning a V3. 

This kind of thing would merit a response with more swear words than a box-set of Billy Connolly: The SCVMM team said “OK”,(was there a lot of swearing first ?) And 13 months  after shipping their 2007 version, the 2008 version Released To Manufacturing today (See Zane’s post here),  It now manages Hyper-V and VMWare, and has added additional key features like Cluster support, Delegated Administration and resource optimization with “PRO” –I love the joined-upness of pro “Operations manager says it looks like this Machine needs to go off line, do you want to start moving VMs off it ?”

I don’t want to give the impression of belittling the work of the Hyper-V team; but in a sense the job of their product is to just blend into the infrastructure, to become invisible,become a given like file sharing. What’s going to matter to customers in 2 or 3 or 5 years is not what they use to do virtualization (Microsoft/VMware/Citrix/whoever) but how well they manage the whole environment where virtualization is in use, from Hardware to the Application in the Guest OS. In that sense SCVMM is the more important product. Virtualization is moving from the early-adopters to mainstream use but today the entrenched VMware customers I meet are – almost by definition - early adopters of virtualization. They’ve listened to stuff about Hyper-V and said yes it’s all very nice but we’ve got VMware, we know where we are with it, and don’t feel like making a strategic change just yet. Then they see SCVMM and before I can get into the business of “Now, you need this because …” their reaction is “We know why we we need it. When can we get it and how much does it cost”. Today (eval here)  and less than you might expect.

PowerShell and Windows Media Player, part 1

Stange bedfellows you might think but why shouldn’t media be scripted ?

I was thinking this a couple of weeks ago. I wanted to run a video before I started a presentation. If the Presentation is due to start at 10:00, and the video is 3 minutes I want to the video to start automatically at 9:57, and step onto the stage at 10:00 exactly as it finishes. I cobbled something together to do that but I didn’t like it. Actually I want to play music before the video. I want a play list of tracks to start at the right time, I want the last one to fade out and go into the video. If people are in their seats before the video starts I want something counting down on screen. Etc.

Now Windows Media Player has an object model and I’ve used it before so how hard could it be ? It turned out to be a little harder than I thought because the object I used in a bit of VB.net aeons ago doesn’t seem to like running in PowerShell. I found Saveen was using a different object so I typed in

$wmp = New-object  –COM WMPlayer.OCX

and I was away… but compared with other things I have worked with recently the Object model is – backward is the nicest word I can use. I can get a play list and I’d expect to be able to do “For each item in list.tracks”. But no: you have to go call list.item(track Number) for each track. To get a playlist you have to request it by name from the “playlist collection” object.  You have to specify the exact name – no wild cards. Yet it comes back as a collection, which again doesn’t work with forEach. Grrr. So I wrote a function to get a playlist.

Function get-Playlist   
{param ($Name)
if ($Name -eq $null) {$wmp.currentPlayList}
else {$list=$wmp.playlistCollection.getByName($Name) 0..($list.count - 1)|foreach {$list.item($_) } }
}

If the name isn’t specified the function returns the currently playing list, otherwise it gets the named list, and it outputs each list found. All 1 of them.
Next came Set-Playlist – I wanted to be able to do Set-PlayList $listObject or set-playlist “random” or get-Playlist “random” | set-playlist so this became a filter

filter Set-Playlist

{param ($Playlist)
if ($playlist -eq $null) {$playList=$_}
if ($playlist -is [string]) {$playlist=get-playlist $playList}
if ($Playlist -is [system.__ComObject]) {$WMP.currentPlaylist = $playlist}
}

Of Course I wanted to see the tracks in a play list so that became the next function – again set up to take Piped input, or a name or an object

filter get-MediaInPlaylist  
{param ($Playlist)
if ($playlist -eq $null) {$playList=$_}
if ($playlist -is [string]) {$playlist=Get-Playlist $playList}
if ($playlist -eq $null) {$playList=$wmp.currentPlayList}
0..($Playlist.count - 1) | foreach {$playlist.item($_) }
$playlist=$null
}

Getting media which is not in an existing play list involves a query to the mediaCollection object there is get media by name, get media by artist and get media by album. It turns out that any attempt to get media returns a playlist, I could have left it that way and te results could be piped into set-playlist but I wanted to see the tracks, so that was how I built the next function.

function get-media 

{param ($Name, [Switch]$album, [Switch]$artist)
if ($artist)    {$wmp.mediaCollection.getByAuthor($Name)| get-MediaInPlaylist }
elseif ($album) {$wmp.mediaCollection.getByAlbum($Name) | get-MediaInPlaylist }
else {$wmp.mediaCollection.GetByName($name) | get-MediaInPlaylist } 
}

There’s also a get media by attribute so you can say “Find me all files where the format is MP3.”

function get-mediaByAttribute 
{param ($attribute, $value)
$wmp.mediaCollection.getByAttribute($Attribute,$value)  | get-MediaInPlaylist }

Next I wanted to be able to add the items I’d just found to the current playlist – so in came Append media, and to make sure I could start with an empty list so did Reset-Media.

filter Append-Media

{param ($item , $Playlist)
if ($Item -eq $null) {$Item=$_}
if ($playlist -is [string]) {$playlist=get-playlist $playList}
if ($playlist -eq $null) {$playList=$wmp.currentPlayList}
$playList.appendItem($item)
$item=$null }
Function reset-media {$wmp.currentPlaylist=$wmp.newPlaylist("Playlist","") }

Finally (for now ) came starting and stopping the playlist.

Function Start-media   {$wmp.controls.play() }
Function Stop-media  {$wmp.controls.stop() } 

Function Pause-media {$wmp.controls.pause() }

 

In the next post I’ll look at waiting for the media to do things, fading music up and down, why this is no good for video and what to do about it.

More Posts Next page »
 
Page view tracker