Index Time EntryType Source InstanceID Message ----- ---- --------- ------ ---------- ------- 12962 Jul 31 12:44 Information HHCTRL 1904 The description for Event ID '1904' in Source 'HHC TRL' cannot be found. The local computer may not have the necessary registry information or message DLL files to display the message, or you may not have permission to access them. The following inf ormation is part of the event:'about:blank', 'http ://go.microsoft.com/fwlink?LinkID=45840' 12961 Jul 31 12:39 Information Com4QLBEx 0 The description for Event ID '0' in Source 'Com4QL BEx' cannot be found. The local computer may not have the necessary registry information or message DLL files to display the message, or you may not have permission to access them. The following inf ormation is part of the event:'Service started'

The –wrap parameter gives us the capability to display the full data. This parameter is also available in v1.

Services and processes seem to be a constant source of topics for PowerShell. Probably because they are so fundamental to Windows. I wanted to see the relationship between a service and its underlying process.

What we need to do is get the services and find the process id and use that to match it to the underlying process. This sort of problem I would usually create an object and then use add-member to add the properties as we loop through the services.

I decided to have a go with Add-Type instead.

Add-Type is cmdlet new to PowerShell version 2. If you are not a programmer you possibly looked at the help information, shuddered and moved on. I have done a bit of C# programming but don’t class myself as a programmer (bet all programmers reading this are looking at the class definition as saying – yep). As far as I’m concerned if it works its good.

So we start with Requires so that don’t try and run this in version 1.

We can then create an empty array. So far so good.

The next bit is where we create a .NET class. A class is what we use when we create an object – think of it in this case as a template. The stuff in the here string $source=@”………..”@ is the C# code that defines the class.

public means that we can access it. ServProc is its name. We then have four properties which are created

by supplying a name eg Displayname and a data type eg string. We also supply a get and set which do what they say. Set is usewd when we set the property and get when we read it. The

private string _displayname;

in effect defines a private variable that is used inside the class. C# IS CASE SENSITIVE!!! and expects a ; as a line terminator

Add-Type is used to create the class.

The Win32_Service WMI class can be used to get the service side information. We create a new object using our class and then set the properties. Notice that we can use the properties of the object as soon as we have created it to get the process name.

Our object is added to the array and we loop for the next service.

Final line of the script displays the data .

The hardest part of using add-type is remembering how to define the properties in C#. Is it worth doing this compared to Add-Member?

It makes the working part of the script neater but makes the earlier part more complicated. If you are not happy with C# probably not for you though other languages can be used. On the other hand if all you want is an object with some properties you have a template here that can be re-used. Just create a private variable for each property and make sure you get the data type right.

Will I use this instead of Add-Member – probably. Especially where I am creating a module with a number of functions that will use the same object.

It wasn’t as difficult as I thought – but I would definitely put this in the advanced PowerShell bucket for now.

But if the value isn't set it means we are using the default which changes depending on the version of Windows used to create the forest in the first place. If we have upgraded then the value may not be what we think it is.

So far I haven’t found a way to get the original version of Windows used to create the forest. It may not be possible in which case time for a rethink

Best guess is that the PowerShell Team have been concentrating on Windows 7\2008 R2 and that the final testing, fixing and packaging needs to be done for the other platforms. Remember how the Vista install package for PowerShell v1 came out a couple of months after the other versions.

Our intrepid presenter is sent to the wilds of Northern England and must deliver the Live Meeting to the PowerShell UG from his hotle room. No problem.

First problem is that the network in the hotel isn’t playing the game (thats English understatement for broken). It will occassionally let him connect but not won’t connect to any of the interesting sites on the Internet. No! Not that sort of interesting. Interesting as is useful like hotmail or blogs of even Live Meeting.

All the usual attempts were made to rectify the problem – try another machine, try a different time, try different part of hotel Eventually the evil deed could be postponed no longer……. the help desk had to be rung <gulp>

One quick restart of the router and connection is made. Whew.

Same problem Tuesday, and Wednesday. This isn’t good news. Ring help desk again and explain sweetly how much pain they are causing – OK you know me too well – Ring up, have major rant and give up.

Why during all this can I still connect to work email – I’m not paranoid they are out to get me.

Thursday morning connectivity looks good & can connect. Just to be safe email friends and arrange for someone to to explain circumstances if can’t connect.

Well to be strictly correct it works in a UK locale and I’m assuming it works for other non-US locales. As previous versions of Excel threw a wobbly and we had to use an awful work around this is a step forward.

Now we need true PowerShell support for Office 🙂

I know the OpenXml PowerShell functionality has been extended. Time to try that against Office 2010