Get remote Best Practice Analyzer results through PowerShell

Today I received an email from a community member where he wrote that he was writing a PowerShell script that basically does the same thing at the Microsoft Best Practice Analyzer.
Why? Couldn’t you just use the BPA to do all the work for you? The answer is both yes and no…

The BestPractices cmdlets don’t have a -ComputerName parameter, so no native remoting in them.
Because of this I’ve chosen to use PowerShell remoting to execute the BestPractices cmdlets on the remote device, but as it seems some checks see that they are invoked remotely and provide you the message that they won’t work:

Kind to give a message stating this, but that isn’t very nice! So, one can’t execute all tests remotely?
When you use PowerShell remoting, the command is actually executed on the remote device as if you where actually sitting at the device.
So why the h*ll would that be a problem?
I can’t answer that one… 🙁

Anywayz, back on topic.
Getting the results is a two-step process.
First you have to execute the BPA. Secondly, when the first is done, you can get the results.
To get kick off the BPA, I’ve written the following function:

Next up will be to get the results. The following function allows you to do this:

Please note that since this is part of a rather large script I’ve been working on, I have chosen not to make the second function dependable on wether or not the tasks the first functions executes are finished or not. So, the second function doesn’t wait for the BPA to be executed…

But… because I use PowerShell remoting an extra property gets attached, namely the PSComputerName property.
Since I don’t want to see ‘PSComputerName’ but just ‘ComputerName’ (without the PS).
You can easily solve this by customizing the name of the expression, when you call the function:


  1. Great stuff! It’s a shame that the BPA reports are dependent upon 2008 R2 though. I’m looking forward to seeing your larger project 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *