James O'Neill's Blog

October 31, 2008

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!

This post originally appeared on my technet blog.

October 27, 2008

Scheduling task on Server 2008 – a Hyper-V snapshot

Filed under: Powershell,Virtualization,Windows Server,Windows Server 2008 — jamesone111 @ 3:42 pm

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.

This post originally appeared on my technet blog.

Mary Jo Foley and Windows pet peeves.

Filed under: Events,Windows Vista — jamesone111 @ 3:33 pm

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 !

This post originally appeared on my technet blog.

Tech-ed for IT professionals next week

Filed under: Events — jamesone111 @ 3:04 pm

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.

This post originally appeared on my technet blog.

October 25, 2008

Virtualize or Virtualise ?

Filed under: General musings — jamesone111 @ 10:31 am

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).

This post originally appeared on my technet blog.

October 21, 2008

PowerShell and Windows Media Player, part 2

Filed under: Uncategorized — jamesone111 @ 11:39 pm

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) }
}

 

This post originally appeared on my technet blog.

SCVMM 2008 released.

Filed under: Virtualization,Windows Server,Windows Server 2008 — jamesone111 @ 5:10 pm

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.

This post originally appeared on my technet blog.

PowerShell and Windows Media Player, part 1

Filed under: Music and Media,Powershell,Windows Vista — jamesone111 @ 3:13 pm

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.

This post originally appeared on my technet blog.

PowerShell, WMI and formatting

Filed under: Powershell,Windows Server,Windows Server 2008 — jamesone111 @ 1:25 pm

I’ve been doing a ton of PowerShell recently, in which is part of the reason why the number of blog posts I’ve made has been down. One of the jobs has been to go back to some of the code I wrote a while back and examine how I handle WMI objects. At the time I wrote my contribution to the OCS resource kit last year I was pretty new to PowerShell and I wish I knew what I know now before I started.


Actually where I started with OCS and PowerShell was looking at someone else’s code where they had for loop with a bunch of write-host statements to output WMI objects to the screen. I said “don’t be daft, use | format-table” and the next thing I knew I was being asked to bring my obvious expertise to bear on the project (A Polite form of “if you’re so clever you do it then” ). So I started with a Bunch of get-thing functions. These would be in the form Get-WMIObject –Class Thing | format table. I quickly realised that wasn’t right because once it is formatted as a table you can’t use the object. So for every class of “thing” I made the get-thing function  return the WMI object(s) and had a list-thing function. One of the testers didn’t like the unformatted WMI objects if he used get- instread of list and I told him that was just how things had to be.


Lets move forward to recent history. I was looking at the Get-process function in PowerShell, when you run it it looks like this.

PS C:\Users\jamesone\Documents\windowsPowershell> get-process -Name winword 

 


Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
——-  ——    —–      —– —–   ——     — ———–
    931     123    85380     149360   506 …86.16    264 WINWORD


Only one thing wrong with that – if you send it to get-member you see it is a “System.Diagnostics.Process” object but those properties “NPM(K)” and the rest the don’t exist. Curious. I already knew PowerShell has some XML files which let me spot-weld properties onto objects, so I went for a little search using my favourite function Select-String.

PS C:\Users\jamesone\Documents\windowsPowershell> cd $pshome

PS C:\Windows\System32\WindowsPowerShell\v1.0> select-string -path *.ps1xml -simplematch “System.Diagnostics.Process”

DotNetTypes.format.ps1xml:370:                <TypeName>System.Diagnostics.ProcessModule</TypeName>
DotNetTypes.format.ps1xml:404:                <TypeName>System.Diagnostics.Process</TypeName>
DotNetTypes.format.ps1xml:405:                <TypeName>Deserialized.System.Diagnostics.Process</TypeName>

DotNetTypes.format.ps1xml:551:                <TypeName>System.Diagnostics.Process</TypeName>

DotNetTypes.format.ps1xml:598:                <TypeName>System.Diagnostics.Process</TypeName>

DotNetTypes.format.ps1xml:1090:                <TypeName>System.Diagnostics.Process</TypeName>

types.ps1xml:133:        <Name>System.Diagnostics.ProcessModule</Name>

types.ps1xml:327:        <Name>System.Diagnostics.Process</Name>

types.ps1xml:430:        <Name>Deserialized.System.Diagnostics.Process</Name>


The files themselves are signed so they shouldn’t be changed, but you can look at them.


In Types.Ps1XML there is a section starting at line 327 which defines the “spot-welded” properties. Have a look at a process in you’ll see alias properties like “NPM” which aren’t part of the definition of the .NET object, that’s where they come from.


In DotNetTypes.format.ps1xml there is a section which describes how the object should be formatted, table or list, column widths and headings, and properties or code blocks. It’s all written up on MSDN. So I could use this as the basis for my own XML file: load that using Update-FormatData and… job done. 


The gist of the XML file is it looks like this

<Configuration>

    <ViewDefinitions>
     </ViewDefinitions>
</Configuration>

Inside viewDefinitions there are one or more <view> objects. Which look like this, the key piece is the name of the type, as you can see this one is for a virtual machine in Hyper-V, and this one is formatted using a table.

  <View>
    <Name>Msvm_ComputerSystem</Name>

    <ViewSelectedBy>
      <TypeName>System.Management.ManagementObject#root\Virtualization\Msvm_ComputerSystem</TypeName>
</ViewSelectedBy>
     <TableControl>
<TableHeaders>
      </TableHeaders>
       <TableRowEntries>
          <TableRowEntry>
          </TableRowEntry>
        </TableRowEntries>
     </TableControl>
   </View>
The Table headers section contains one entry for each column
  <TableColumnHeader>
<Label>Up-Time (mS)</Label>
<Width>12</Width>
<Alignment>left</Alignment>
</TableColumnHeader>

And the TableRowEntry section contains a corresponding entry

  <TableColumnItem>
<PropertyName>OnTimeInMilliseconds</PropertyName>
</TableColumnItem>

If I wanted to have the time in seconds here I could use a script block instead of a property name
  <TableColumnItem> 
<ScriptBlock>$_.OnTimeInMilliseconds / 1000<ScriptBlock>
</TableColumnItem>

I’m not going pretend that putting the XML together is as quick as writing a list function – but it definitely seems worth it. 


Technorati Tags: ,,,,

This post originally appeared on my technet blog.

October 20, 2008

Hyper-v Server , what is it exactly ?

Filed under: Virtualization,Windows Server,Windows Server 2008 — jamesone111 @ 12:07 pm

I’ve got multiple blog posts on the go in Windows Live Writer at the moment, one talking of the relative dearth of posts recently. Last week the folks at VMware put up another post about Hyper-V server and in it actually found something nice to say about me (even if they mis-spelled my name. double-L guys, like the wet-suit and surf gear maker).  I’ve got to say something nice about them and getting products certified, but that’s another post.

Before this becomes a love-in, lets get back to Hyper-V Server … what is it then ? From the point it was first mooted, we’ve been saying that the easiest way to picture Hyper-V server is as Windows Server 2008 Standard Edition, Core Installation, with only the Hyper-V role available. That is an over simplification but as a first approximation it will do. In that post VMware’s Tim Stephan post says “I am actually thinking that, at the time of Hyper-V server’s announcement, Microsoft itself didn’t know what the Hyper-V Server 2008 architecture would look like…”. Not so: the idea of Server Core (standard) with all the bits what weren’t needed removed has been pretty constant even if the odd wrinkle needed ironing out between announcing and shipping.

The VMware post says “Hyper-V Server is supposedly Microsoft’s ‘thin’ hypervisor that doesn’t require Windows Server OS in the parent partition – as reported by Microsoft here.” 

“Here” is Post of Patrick’s where doesn’t say those things. He does say:

  • Hyper-V Server 2008 was built using the Windows hypervisor and other components, including base kernel and driver technologies. Microsoft Hyper-V Server 2008 shares kernel components with Windows Server 2008.
  • Microsoft Hyper-V Server 2008 contains a sub-set of components that make up Server Core deployment option of Windows Server 2008, and has a similar interface and look and feel. But as you know, Server Core has roles like DNS, DHCP, file. Hyper-V Server 2008 is just virtualization.

  • Because Hyper-V Server 2008 shares kernel components with Windows Server 2008, we don’t expect special hardware drivers to be required to run Microsoft Hyper-V Server

So, strictly speaking, it isn’t the Windows Server OS in the parent partition, but everything which IS in the parent is from Windows. If it wasn’t, you wouldn’t be able to manage Hyper-v Server like Windows Hyper-V, you wouldn’t be able to use the same drivers use the same patch process and so on.  And since I mention patching, do you need to download the same patches as for Windows Server 2008, Standard, core with only the hyper-V role ? Yes. The guys at VMware found that out. Incidentally, the client Windows Update uses some parts of internet Explorer to get updates over HTTP, and to find and connect through proxy servers. It might feel wrong to be applying an IE patch to Hyper-v server or Server core, but that’s the reason and not every IE patch will be needed.  Running a Microsoft OS in VMs, and as the host everything get’s patched together. Customers can judge VMware’s Patch record and Server 2008’s for themselves; I’m happy to be on the Microsoft side in that one.

One might quibble with their sensationalist tone “Microsoft OS based on Windows shock” … what did they expect, VHD’s stored on a whole new file system ? Windows PE as the management partition ? A whole new driver model ? They come to the conclusion that the easiest way to picture Hyper-V server is as Windows Server 2008 Standard Edition, Core Installation, with only the Hyper-V role available, as if we hadn’t been saying since before it was announced.

So does the rest of the Tim’s peice introduce any new FUD or distortions. Not really. Their comparison chart is the same old spin

  • Having laboured the point that Hyper-v Server is based on Windows, they claim it isn’t production proven, and is hard to move VMs to other products in the Microsoft family. I don’t think the facts justify those opinions (no surprise in that) But what constitutes an easy upgrade ? What constitutes production proven … do you need more proof or less than the next customer ? I don’t trust things which present opinions as facts (people point out when I do it, and I when I’m not clear I get annoyed with myself). 
  • Memory support in Hyper-V Server is capped at 32GB like Windows Server standard. There’s no clustering support (like Windows Server Standard).
  • VMware takes up less disk space than its competitors (though with disk space these days costing less than £0.10 per GB I’m never sure why they bring that up. VMware has a bigger memory foot print (see this post from Roger Klorese ) – depending on configuration Hyper-V uses about 200MB less. So no-one should be surprised that they gloss over that one.
  • I’m suspicious of their Supported guest OSes figure. Our 11 is “OSes which you can call Microsoft support and get a fix for if they don’t behave properly on Hyper-V”. We don’t support NT4 on anything any more. There’s actually a check box in Hyper-V to make it run better, but running well is not the same in Microsoft product-support parlance as supported. My understanding is that their 30 is “OSes which are known to work”, so that would include NT4. I’m not going to argue for any particular definition of “supported” but you can’t make a valid comparison unless the definitions are the same.

This post originally appeared on my technet blog.

October 17, 2008

Dude, where’s my script ?

Filed under: Uncategorized — jamesone111 @ 6:53 pm

I’ve been working on a PowerShell script over the last few days which uses an XML file. (That’s another post in the stack). I had a nagging question about how to figure out where the script file is in order to because that’s where the XML file needs to be loaded from. Fortunately someone else threw a near identical question to our discussion list internally and Lee Holmes came up with answer – it’s in the sample from his PowerShell Cookbook

To determine the location of the currently executing script, use this function:

function Get-ScriptPath
{     Split-Path $myInvocation.ScriptName 

}

I’ve used $myInvocation before. People pick up one of the script libraries I put together, when they are new to PowerShell, and rarely know that they need “Dot Source” a library – i.e. invoke it as . script name

So now I have this at the end of my library scripts.

if ($myinvocation.line -match "^\.\s") {"Functions loaded" } 
Else {write-host -ForegroundColor red "No Functions were loaded - you need to invoke with . scriptname "}

A little bit of regular expression checks the line starts with . followed by a space. (The first try checked just for a space and anyone who run the script .\scriptName), and then the script either reports the functions have been loaded or tell the user the right way to load them. 

But I had a bit of trouble with Lee’s one liner. It turns out that in a script which uses $myInvocation.ScriptName outside a function Scriptname is empty: $myinvocation contains the command line used to run the script in the Line property and the name name of the script itself (without the path) in the MyCommand  property. If PowerShell found the script on the path it won’t work.  But inside a function the command-line property is the line of script that called the function the scriptname property contains the name of the script that holds the command line.

So I tried this.

PS C:\Users\jamesone\Documents\windowsPowershell> set-content Invoke.ps1 "where_am_I -fake parameter"
PS C:\Users\jamesone\Documents\windowsPowershell> function where_am_i {$myInvocation}
PS C:\Users\jamesone\Documents\windowsPowershell> .\invoke

MyCommand        : where_am_i
ScriptLineNumber : 1
OffsetInLine     : -2147483648
ScriptName       : C:\Users\jamesone\Documents\windowsPowershell\Invoke.ps1
Line             : where_am_I -fake parameter

Ah ha !  That’s clever. The function doesn’t need to be in the script, but it can know which line from which script called it.  And Split-Path divides the folder from the from file name. Though I will probably name the function get-ScriptFolder

This post originally appeared on my technet blog.

October 15, 2008

Not just rewarding failure: 25% off voucher for passing exams.

Filed under: Uncategorized — jamesone111 @ 2:12 pm

For a while now we’ve had a program called second shot for people taking MCP exams. Take an exam and if you fail you get a second shot at it on us. All very fine and good, breaking down barriers to people doing the exam if they’re afraid of wasting their money and so on. But if you passed the exam what did you get ? Nothing.You paid full price for the test, and in effect subsidized the person who didn’t prepare properly. Well Second shot is changing to give something to people who pass. From now until the end of the year you still get a free re-sit if fail any exam you’ve paid full price for, but if you pass you get a 25% off voucher for another exam to be taken before the end of February. As they say “terms and conditions apply” but you can see the details at http://www.microsoft.com/learning/mcp/offers/secondshot/default.mspx. Just be confident of passing your discounted exam, because that doesn’t have a free re-sit.

Technorati Tags: ,,,

This post originally appeared on my technet blog.

October 11, 2008

I, Assassin.

Filed under: Uncategorized — jamesone111 @ 11:54 pm

[Another one of those looping posts for the weekend]

I’ve been feeling a bit of pressure to get some stuff written and getting increasingly grumpy about the amount of background noise. Working on something last weekend, I lost it with the family because “I can’t hear myself think”. I’ve told several people that recently that the hubbub in our hotdesk area has got to the point that I come to the office to meet people, but to do work I stay at home. Reading Sharon’s blog I came across chatter blocker. Something jumped out of the page at me. ChatterBlocker may also be helpful for Asperger syndrome (with sound sensitivity). I’ve had a few people suggest to me that I might have Asperger’s . To be frank I don’t care if I do or not though it might explain things for other people.  I did an on-line survey which suggests I might: (one question is “I often notice small sounds when others do not.”)

One of the questions  in that survey was “I usually notice car number plates or similar strings of information.”. I do. If I see a truck with its company’s name – say “Jones of Cumbria” , and a phone number – say one with a 01228 dialling code I’ll work out that 01228 is the code for Carlisle. (2  is ABC, so 22 is AB, AC, BA, CA – nowhere in Britain begins AA, BB, BC, CC or CB. But Cambridge, Aberdeen, Bath, Barnsley all have codes beginning 012. ) On Monday, Exchange gave me missed a call notification and then a voice mail from an 01246 number. I couldn’t play back the voice mail (I was sitting in a training session) – who wanted to call me?  2 is ABC, 4 is GHI so that’s AG, AH, AI, BI, CH, CI … from many possibles, 01246 turns out to be Chesterfield. I don’t know anyone in Chesterfield. I needed to duck out an listen to the voice mail: my replacement car was ready for delivery.

So Wednesday meant handing back Lima Charlie . The the number of the old car began “LC” which gave it an identity  not so much as a car but as a Peruvian drug dealer. The new car arrived having never been to Chesterfield. It was brought from Doncaster, (that would be an 0130x area code) with a  number starting SJ – meaning although it’s never been to Scotland, that’s where it was registered (Sx is scotland, Lx is London, Cx is Wales , Rx is Reading, Bx is Birmingham and so on). Sierra Juliet… it’s going to be a battle not to think of this car as “Big Julie” from Doncaster (I’d got Doncaster muddled up with Rotherham and was well on the road to thinking of the car as someone from Jamie Oliver’s new TV programme. She’d make an unlikely companion for Jacques Chirac). Fortunately the car gets an alter-ego: the number ends LR – Lima Romeo, another Peruvian either a tango instructor or a Mafia hit-man.

Since I’ve brought up those two towns, here are two Jeremy Clarkson related co-incidences; first he was born in Doncaster and trained as a journalist on the Rotherham advertiser… I glided home in a very agreeable silence –feeling like a French president who’d sent the chauffer home for the day. (Though I’m a bit better with the traffic laws than M. Sarkozy . Citroen’s trick suspension enabled DeGaulle’s DS to escape an Assassination attempt with two types shot out.).  I turned on the TV to find Dave showing The episode of Top gear where Clarkson raves about the C6. (My second Clarkson coincidence: with 100 plus episodes to show, they were showing that one.). He said it’s the kind of car which “that French actor, the one in Leon” would drive: sadly the actor is M. Reno which sounds enough like Renault for his choice of car to be pre-ordained. As a throw-away he says people would assume you were an assassin in a C6. 

Back at that on-line survey another question was I prefer to do things the same way over and over again. Ah yes 7 Citroens in 20 years. I brought in my CD single of Gary Numan’s Cars to play in the car on the way home. It’s been the first CD I played in each of my last 5 cars. I, Assassin is one of his Albums, and he has been diagnosed with Aspergers.

[Loop closed.]

This post originally appeared on my technet blog.

October 10, 2008

Never, ever run executables which arrive unexpectedly by mail.

Filed under: Security and Malware — jamesone111 @ 10:12 am

I had this waiting for me on my home PC this morning.

From: Microsoft [mailto:customerservice@microsoft.com]
Sent: 10 October 2008 02:25
To: {My home account}
Subject: Security Update for OS Microsoft Windows

Dear Microsoft Customer,

Please notice that Microsoft company has recently issued a Security Update for OS Microsoft Windows. The update applies to the following OS versions:

Microsoft Windows 98, Microsoft Windows 2000, Microsoft Windows Millenium, Microsoft Windows XP, Microsoft Windows Vista.

Please notice, that present update applies to high-priority updates category. In order to help protect your computer against security threats and performance problems, we strongly recommend you to install this update.

Since public distribution of this Update through the official website http://www.microsoft.com would have result in efficient creation of a malicious software, we made a decision to issue an experimental private version of an update for all Microsoft Windows OS users.

As your computer is set to receive notifications when new updates are available, you have received this notice.

In order to start the update, please follow the step-by-step instruction:

1. Run the file, that you have received along with this message.

2. Carefully follow all the instructions you see on the screen.

If nothing changes after you have run the file, probably in the settings of your OS you have an indication to run all the updates at a background routine. In that case, at this point the upgrade of your OS will be finished.

We apologize for any inconvenience this back order may be causing you.

Thank you,

Steve Lipner

Director of Security Assurance

Microsoft Corp.

—–BEGIN PGP SIGNATURE—–

Version: PGP 7.1

Now there are a number of things which jump out and say THIS IS A FAKE , notably the greeting “Dear Customer” [someone who has your email address but not your name is suspicious for starters], the grammatical errors and clumsy English the incorrect names. Also the fact that when you sign up for Windows update, Microsoft don’t get your e-mail address.  I give it a plausibility rating of about 3 out 10. But this seems a good time to remind people Never, ever run executables which arrive unexpectedly by mail. Outlook has blocked executables for since about 2002 so I didn’t get to see what the file was – although it was named to make it look like a valid patch.

The same rules apply to mails which tell you to go to a web site and enter information. My bank, e-bay and paypal have all said much the same thing. “If we need you to do something on-line we will send you a mail which addresses you by name, and says go to the normal web site, log on normally and then follow these steps. Anything which says dear customer, click this link and enter private information is a fake.”

YOU probably know this already. By all means warn people about this specific mail, but far better to remind people you know who might be taken in of these basic rules.

This post originally appeared on my technet blog.

October 8, 2008

Server 2008 AD Free Exams …

Filed under: Windows Server,Windows Server 2008 — jamesone111 @ 10:44 pm

I just had this in my mail with a request to share.  Most requests to “blog this” are on a fast track to the great electron recycler, but this is worth sharing. Here’s what

Registration is open till October 25th for testing New Virtual Lab based Exam 70-113: TS: Windows® Server 2008 Active Directory, Configuring

The new pilot exam “70-113: TS: Windows® Server 2008 Active Directory, Configuring” tests candidate’s abilities to actually perform tasks and solve problems in virtual lab environment like they would do it normally in a real world. We are pleased to offer you the opportunity to experience this pilot exam at no charge …

This pilot exam will not provide you with a score as with normal beta exams. This pilot is a test of the exam experience, so only a portion of the final exam will be presented to you during this pilot.

This pilot exam will not be added to your transcript and you will need to take the exam in its released form in order to be awarded the credential. Find exam preparation information: http://www.microsoft.com/learning/exams/70-640.mspx

An exam that doesn’t count. Apart from Masochism, why would you want to do it ? Here’s why

Upon completion of this pilot exam, the first 3000 candidates will receive 3 (!) free exam vouchers that can be used to register for any Microsoft Certification exam delivered at a Prometric testing center. 
The voucher will be distributed electronically 4 weeks after end of Pilot.

Apart from needing multiple visits to the test centre that’s a much better deal than the usual free beta (spend 2 or 3 times as long on the exam, but get it for free).  Here’s how to do it.

You must register at least 7 days prior to taking the exam. Register before October 25th to take the exam before October 31st.

Send your opinion about exam experience to: http://blogs.technet.com/betaexams/ and to: pbexam@microsoft.com

I didn’t even know there was a beta exams blog – I’ve done enough of them in my time. Sadly I won’t be able to fit this one in before the time runs out.

This post originally appeared on my technet blog.

Blog at WordPress.com.