Over on the Stack Overflow site, there’s a fascinating question and answer(s) about little known features of PowerShell. See What are some of the most useful yet little known features in the PowerShell language for this article. If you are a PowerShell geek, you probably know these, but there are one or two that you might have missed!
Thomas Lee's collection of random interesting items, views on things, mainly IT related, as well as the occasional rant
Sunday, May 24, 2009
Saturday, May 23, 2009
TechNet Virtual Conference 2009
Where are you going to be on June 19th? If you are a techie and into Microsoft technology, then perhaps you should be attending TechNet’s free Online Conference. This is an all day, free, on-line event aimed at delivering technical information that the community requested. And did I mention, unlike other events you have to pay for, this conference is free!
The conference is divided up into two tracks: Technology and IT Manager, with content to match. See the web page: TechNet Virtual Conference 2009 for more details on the agenda.
This is an excellent idea and I am definitely looking forward to hearing Richard Siddaway and Brent Johnson in particular. I’m sure glad the sessions are recorded so I can view later the sessions I missed!
See you on-line.
Friday, May 22, 2009
PowerShell and WMI Namespaces
Over on Tim Benninghoff blog – he has an interesting post:: PowerShell and WMI namespaces. With WMI, the classes and intances are organised under a hierarchal namespace starting at the appropriately named “root”. Individual nodes can have children which can in turn have children and so on. To some degree, namespaces are just defined by a product team and there is little consistency across software products (such is life!). But where to start?
Despite what Tim says about using the GUI, MOW’s most excellent WMI Explorer script is one fantastic tool. Not only is it a really good browser, but as Tim notes, it’s written in PowerShell which is even more cool. I use this script in most of my training courses to add value!
His post then goes on to describe two methods of obtaining the namespaces within WMI. There are two small problems with his examples. In his first example he has a minor typo – this should read as follows:
gwmi -namespace "root" -class "__Namespace" | Select Name
In Tim’s post, he spelt the class with just a single underline (“_Namespace”) not two (“__Namespace”). WMI is sadly very picky! Tim’s other method works fine and as he says produces the same output as his first (well once corrected!). On my system, this produces the following output:
PSH [C:\foo]: gwmi -namespace "root" -class "__Namespace" | Select Name
Name
----
subscription
DEFAULT
MicrosoftDfs
CIMV2
Cli
nap
MicrosoftIISv2
SECURITY
RSOP
MicrosoftDNS
WebAdministration
WMI
directory
Policy
virtualization
Hardware
ServiceModel
MSAPPS12
Microsoft
aspnet
The second point is that his two methods just produce a list of namespaces under the root. Since each node in the namespace can have children, his two methods do not list all the namespaces in which you can find classes. This, IMHO, is once case where the GUI is a better tool – visualising the hierarchy in a tree control is a whole lot easier than trying to do it from the command line. And you get the names spaces in alphabetical order (although you could do pipe the output above to Sort-Object easily enough). On my workstation I see a number of subsidiary namespaces below root as you can see here:
WMI Namespaces are a good thing to understand, since many of the classes you might want to access using Get-WMIObject (et al) rely on the –NameSpace paramater (and the appropriate namespace name!).
Thursday, May 21, 2009
Windows Vista for XP Professionals
I’ve been carrying this book (see http://www.amazon.co.uk/Windows-Vista-XP-Professionals-Updating/dp/9072389018 to buy this book!) . It’s written by Dutch MCT superstar Raymond Comvalius. In summary, this is a great book – simple and to the point. Unlike some books, there’s very few screen shots – just lots of good straightforward text!
The book contains 8 chapters:
- Chapter 1 – Introduction
- Chapter 2 – What’s new in Vista and is not discused in the book – a nice touch!
- Chapter 3 – Deploying Vista – a good look at the deployment tools which are all new in Vista.
- Chapter 4 – Managing Vista- includes details on group policies and a look at WInRM.
- Chapter 5 – Securing Vista – explains the key new security features of VIsta including UAC, file/registry virtualization and BitLocker.
- Chapter 6 – Networking – Vista includes a bunch of new networking features, in effect a new TCP/IP stack, which are described in this chapter.
- Chapter 7 – Mobility – a look at the mobile features of Vista.
- Chapter 8 – Migration to Vista – this final chapter examines how to plan your Vista migration.
This is an excellent summary of what an IT Pro needs to know moving forward to Vista. I hope Raymond writes an update for Windows 7!
Wednesday, May 20, 2009
Pscx 1.2 Beta Released
The beta of the next version of the PowerShell Community extensions has been released (see Nivot Ink - Pscx 1.2 Beta Released for more details). The code itself can be downloaded from: http://pscx.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=1615.
For me, the cool thing is that this is released as a module so I can import the module when I want it – or not. Nice touch. If you are using Win 7, note this beta requires Win 7 RC!
Tuesday, May 19, 2009
2009 Summer Scripting Games
As in years past, Microsoft is hosting the 2009 Summer Scripting Games. This year, the games are co-promoted by The Microsoft Script Guys and PosCode.Org. The games will run from June 15-26 and should be a lot of fun. As happened last year, I’ve been asked to submit a sample script and am hard at work on it already!
If you are a novice, an expert, or anywhere inbetween with scripting (PowerShell or even VB Script) then visit the site, sign-up and take part.
Wednesday, May 06, 2009
Updates for Communications Server 2007 R2 (almost SP1!)
Microsoft has released a set of 13 patches for OCS 2007 R2. You might think of this as SP1 for OCS 2007 R2 (but that’s not the say MS is marketing it). Irrespective of what they call it, this set of patches is probably worth adding if you are deploying R2. As ever with patches, check the details to see if your systems are affected by each of these patches and which ones.
Due to the complex nature of OCS Deployments, patching is hard as there’s not just a single patch you can apply to all systems – you have to apply some patches on some systems and other patches on other systems. For example, an OCS 2007 R2 SE system needs 9 patches, while the Edge Server needs three. So plan this carefully as, at the least, you’ll need some service outages to apply the fixes.
The KB article: List of available updates for Communications Server 2007 R2: April 2, 2009, lists all 13 patches and describes which patch needs to be installed on which server role. You can drill down into each of the 13 individual patches – each has its own KB article. Most of these KB articles explain the issues resolved by the patch. KB 967675 that describes the fix to the Mediation server does not contain details of the fixes, but that’s probably just a doc error that will get fixed soon. For each individual issue, there’s a link to (another!) KB article describing the specific issue in more detail which include the symptoms of the (resolved) issue.
All in all, this is a useful update and well packaged. Next time though, couldn’t we have a mondo-patch (R2PatchAug09.exe for example) that you must apply to every related OCS system. That would help with the deployment and could reduce support calls especially from organisations deploying distributed Enterprise pools.
Friday, April 24, 2009
Windows Management Infrastructure Blog
The WMI team are now blogging in the Windows Management Infrastructure Blog. A most useful blog for those wanting to understand WMI (and BITS, and WINRM) especially those coming to this from a PowerShell point of view. One interesting post examines the WMI story, pre Windows 7 (with lots of great links to more background). Another post looks at what is coming with WMI in Windows 7 (i.e. with PowerShell V2).
This blog is well written! And any blog that can mix PowerShell, reindeers, Jedis, ands and grasshoppers can’t be all bad!
PowerShell and CMDlet design guidelines.
Dan Harman, a PM in the Windows PowerShell team has published an excellent blog article: Increasing visibility of cmdlet design guidelines. The article talks about cmdlet naming conventions and the importance of good naming around the verbs and nouns used in the names of cmdlets (and by implication advanced functions too). The article also talks about the problems of a proliferation of uses of PowerShell that deviate from the standards currently being set by the PowerShell team.
With the increasing adoption of PowerShell across MS and non-MS products, standards are vital and enforcement probably mandatory. PowerShell aims help organisations break down their knowledge silos. To achieve this, there needs to be a standard set of verbs and nouns you can use and some good way of enforcing it.
Microsoft proposes some changes to V2 to resolve the issue. Specifically, when you call Import-Module to import cmdlets, Powershell evaluates the module and warns against violations of the standards. The end use sees a warning message but the cmdlets are still imported. Thus, by default, when you load a module with badly named cmdlets, you get a warning message but everything works (i.e. the module is imported!). For scripts where you want to suppress the Warning, just use the –DisableNameChecking on the call to Import-Module.
This is a pretty neat solution. We’ve already seen a number of interesting approaches to the use of PowerShell by various teams, and MS is right to want to stop the problem from being a real problem.
One addition I’d like to see: a GPO setting to set a default value to enable disabling name checking. The scenario I envisage is an organisation that has, for whatever reason, invested in cmdlets that end up being badly named. Rather than have their admins constantly be reminded, or worse possibly confused, I’d like to see a GPO setting to always just not show the message for my organisation (or part of an organisation).
Wednesday, April 22, 2009
Saying Thanks
I’ve been posting here to this blog for a few years – and on occasion, I get a nice comment either here on the blog or in email. In September 2006, I published an article entitled Vista Shortcut keys where I described the new short cut keys you can use with Vista. Well today, I got a comment on the blog – it wasn’t much, just a short “thanks” but it sure made my day!
Hey Scripting Guy! Windows Powershell and Pipelining
Just saw a new article from The Scripting Guys (aka Ed Wilson and Craig Liebendorfer). Entitled “Hey Scripting Guy! Windows Powershell and Pipelining”, this article looks at the PowerShell pipeline. It’s a 100-200 level article, but may be helpful to learn more about the pipeline.This article is one of many that The Scripting Guys pump out – for a complete list, by date, see: http://www.microsoft.com/technet/scriptcenter/resources/qanda/all.mspx. There are 18 articles already for April.
The Scripting Guys Rock! You can also follow them on Twitter: http://twitter.com/scriptingGuys
Tuesday, April 21, 2009
PowerShellASP - Build dynamic web content with PowerShell!
This is pretty cool – integration of ASP.NET and PowerShell. PowerShellASP is an ASP-like template language for Web Applications. You create templates that contain a mixture of mark-up i.e. (HTML, XML or whatever) plus inline PowerShell code. At runtime, your templates/pages are translated to PowerShell code and executed as a single unit inside a PowerShell pipeline. The results are then sent to the client browser.
Setting it up is easy too: see http://www.powershelltoys.com/configuration.aspx. Simple!
Fun and Games with WMI and PowerShell
As I continue to dive deeper into PowerShell WMI, I continue to be surprised by new things I discover. I’ve been playing today with the WMI Class WIN32_printer. Sometime ago, I posted a code sample over on MSDN using this class with Powershell (see the original sample here).
The original sample produced a test page on a specific printer – but I thought it would be interesting to see what happened if I ran the script against ALL the printers define on my workstation. And that got interesting.
On my system, I have two ‘real’ printers installed (a colour Inkjet and a colour laser) and two additional printers: an XPS Document Writer “printer” and a SnagIt 9 “printer”. As expected, the real printers printed their test pages just fine. But the virtual printers did not fare so well. The SnagIt printer failed to print a test page. It generated two “Unable to open message queue” error messages (in a pop-up window), then failed with a message “Unable to send a message to SnagIt” (and another pop-up). But at least it failed gracefully although the Result code was 0. Attempting to print to the XPS document writer just hung.
This result shows that, at least with WMI (and probably ALL other classes), when you start writing scripts based on base objects (i.e. WMI, COM, .NET and home grown), you need to know what you are doing. And in writing production scripts, you need to be extra careful with testing, and coding around the problem issues.
This last point is illustrated in the updated script that I published to my scripts blog: http://pshscripts.blogspot.com/2009/04/get-printertestpageps1.html. Look at lines 63-65 – these avoid calling the PrintTestPage on those printers you know to not work. This is another interesting reference to the fact that production scripting is more about “error” handling (you might call it “reality handling” too"!) than anything else. And a lot of wide testing.
Wednesday, April 15, 2009
Master-PowerShell by Dr. Tobias Weltner
As a PowerShell addict, I love sharing information about the product. I’ve just seen that Dr Tobias Weltner has finished off an e-book, entitled Master-PowerShell. This book is a free, 20-chapter work covering all aspects of PowerShell and is targeted at PowerShell Version 1. Thus, no details on Modules, remoting, etc, but nevertheless containing lots of useful information. I especially enjoyed reading Chapter 18 and learning more about PowerShell and WMI!
I recommend this book!
Master-PowerShell | With Dr. Tobias Weltner - PowerShell.comTuesday, April 14, 2009
Rich Copy – A Must Have Application
A very long time ago, when I was contracting for Microsoft, I got a copy of a cool internal application called Rich Copy – sort of a RoboCopy on steroids. The Internally obtained version of Rich Copy timed out after a while which was a shame.But today, I’ve just read that Rich Copy is available for download from the TechNet site: http://technet.microsoft.com/en-us/magazine/2009.04.utilityspotlight.aspx. This is a very seriously cool app – and it’s free and freely available.
Monday, April 13, 2009
Microsoft Office Protocol Documents – Geek Heaven
I’m just back to the UK after a month on the road, topped off by a week in Redmond attending an OCS Voice Ignite Train-The-Trainer session. Last week was a week in geek heaven. We spent a lot of time exploring the inner workings of OCS. In particular, how OCS operates on the wire – both between servers and between client and server. Fascinating stuff – sheer geek bliss.
Both last week and in my Voice Ignite classes, I see huge interest around how MS has implemented SIP on the Wire within OCS. When looking at OCS wire captures, or SIP logs, you can see a huge number of Microsoft extensions to older style SIP traffic, in addition to the updates to both SDP and RTP. In preparing for my upcoming TechEd talk (SIP – Naked in all it’s Glory), understanding these better has taken on a new importance.
Whilst in Redmond, superstar VI Trainer Dennie Klama pointed me towards updates to the Microsoft Office Protocol Documents. I first came across these last summer, as noted in a blog entitled: Open Geek Goodness From Microsoft. It was cool to get access to this level of detail – although I was disappointed that the documents themselves were not open to Community Content on the MSDN site. Thus there was no way for the community to clarify or perhaps better document the details of the protocol. I’d love to see more real-world examples to illustrate the text better.
Thanks to the pointer from Dennis, I was very exited to see not only more documents than I recall seeing last July, but much more importantly, there have been updates to these documents. The most recent set of updates to the OCS related documents I’ve read so far occurred in March 2009.
You can browse the index to the OPDs on the TechNet site at: http://tfl09.blogspot.com/search?q=protocols. You can also download a zip file of all 61 documents from: http://go.microsoft.com/fwlink/?LinkId=112500.
If you want to understand what OCS is doing on the wire, these documents are a must read.
Wednesday, April 01, 2009
Microsoft accepts defeat to Wikipedia and kills off Encarta
Today’s news that Microsoft accepts defeat to Wikipedia and kills off Encarta, which I read in the on-line version of The Times, is quite sad. But it’s one data point in the huge shift we’re seeing from the older style printed material (and that includes CD/DVDs) to online only.
We’ve seen a number of newspapers stop publishing their print editions, and a magazine I wrote for (Server Management Magazine), I contributed for over 10 years, has also gone web only. Although Encarta was an on-line product too, the death of print media is continuing at a pretty frantic pace.
One could argue the battle was more about the content than online vs offline. For me at least, the content on Wikipedia is very good. Thinking back over the past year, when I needed information, I’ve tended to use Google and Wikipedia. In a few cases, I found Wikipedia entries wanting – so I added some content. Maybe if MS had opened Encarta up more, it’s popularity might have been higher.
As it turns out, Encarta was a very distant 2nd place to Wikipedia. With Wikipedia having 97% market share and Encara being second with 1.27% (and “print” not being significant0, the decision was only a matter of when, not whether.
So farewell Encarta.
Thursday, March 05, 2009
Server Management Magazine- $50 off Idera’s PowerShell Plus deal
I write for Server Management magazine – and over on their web site, there’s a cool offer on PowerShell Plus. For a limited time, Server Management web site readers can take advantage of the offer of $50 off PowerShell Plus, thanks to those very nice people at Idea. With this offer you can download the current version OR the latest beta from the Idera website. You don’t need not wait until the new version comes out to purchase. If you like what you see in the beta, you can purchase the current version and get a free upgrade when the beta becomes GA. Either way – it’s a good deal!
Wednesday, February 25, 2009
SLMgr Commands and Options
I’ve been dealing a lot lately with activation of Server 2008. It’s not been as easy as I’d like. In searching for some help, I came across a great article on SLMgr: SLMgr Commands and Options with Windows Vista Product Key Activation. This article provides a good look at the options with this SLMgr.ext tool.
Tuesday, February 24, 2009
OCS, WMI and PowerShell
This past week, I was teaching OCS Voice Ignite in Munich and a colleague (superstar Robin Edwards). During the week, we chatted about how to configure OCS’s Address Book service. This is a topic that comes up a lot in our OCS training, especially as the Address Book seems to be one of the key troubleshooting issues our delegates encounter.
As it turns out, you cannot do much with the GUI. There’s nothing there to enable you to do much more than view SOME of the settings. For example, by default, OCS ABS keeps 30 days worth of delta address books. If you login to Office Communicator, OC will download only the deltas since the last time you logged in, up to a certainly value – by default 30 days. This is a great feature for very large address books that don’t change a lot week to week.
The problem is, you can’t see this value in the GUI, nor can you set it. To view or change this, you need to use WMI in a direct way. Which leaves you three options: WBEMTest, VBS, or PowerShell. For most admins, WBEMTest is way too ugly and unfriendly and that probably is true for VBS. But PowerShell makes it very, very easy (assuming you know PowerShell of course).
The key settings for the Address Book Server are found in the WMI Class MSFT_SIPAddressBookSettings. This class is defined in MSDN at http://msdn.microsoft.com/en-us/library/bb632067.aspx.
This class has some useful properties, including:
DaysToKeep – specifies the number of days to keep the delta data files. The default is 30.
ExternalURL - An HTTPS URL that specifies the external location for address book file downloads
MaxDeltaFileSizePercentage - The maximum percent of change for which a delta file is created. A delta file is not created if the percent of change is greater than this number. Multiply the value by 0.01 to derive the percentage. The minimum value for this property is 0 and the maximum value is 9999 (99.99%). The default value is 1250 (12.5%).
So much for what it does, now to how to do it with OCS R2. To get this class, using Standard Edition, you just use:
-
Get-WMIObject –Class MSFT_SipAddressbookSetting
However, using EE, it’s a bit more complex and you have to use a slightly different variation on the Get-WMIObject sytax, as follows:
PS C:\foo> gwmi -query "select * from MSFT_SipAddressBookSetting where backend='dc1'" -computer ocs-ee
Backend : dc1
DaysToKeep : 30
ExternalURL :
IgnoreGenericRules : False
InstanceID : {D265A402-BD08-4BCB-BEB3-CC7AFBD47C08}
InternalURL :
https://Cookham.gktrain.net/Abs/Int/Handler
MaxDeltaFileSizePercentage : 1250
OutputLocation : \\ocs-ee\absfiles
PartitionOutputByOU : False
RunTime : 130
SynchronizeNow : False
SynchronizePollingIntervalSecs : 300
UseNormalizationRules : True
WebServiceEnabled : True
So to make some changes, you could do something like this:
PS C:\foo> $abs = gwmi -query "select * from MSFT_SipAddressBookSetting where backend='dc1'" -computer ocs-ee
PS C:\foo> $abs.daystokeep = 45
PS C:\foo> $abs.runtime = 0230
PS C:\foo> $result = $abs.put()PS C:\foo> gwmi -query "select * from MSFT_SipAddressBookSetting where backend='dc1'" -computer ocs-ee
Backend : dc1
DaysToKeep : 45
ExternalURL :
IgnoreGenericRules : False
InstanceID : {D265A402-BD08-4BCB-BEB3-CC7AFBD47C08}
InternalURL : https://Cookham.gktrain.net/Abs/Int/Handler
MaxDeltaFileSizePercentage : 1250
OutputLocation : \\ocs-ee\absfiles
PartitionOutputByOU : False
RunTime : 230
SynchronizeNow : False
SynchronizePollingIntervalSecs : 300
UseNormalizationRules : True
WebServiceEnabled : True
And finally – a bit tip of the hat to superstar Robin Edwards who showed me this class last week. Thanks Rob – you rock!