Microsoft Team Foundation Server Best Practices Analyzer Doesn’t Play Nice With PowerShell 3.012 Nov 2014, by Developer in
Today, I was tasked with getting TFSBPA to work on our TFS servers. We needed to analyze our repositories to see if what we’re doing is considered to be “best practice.”
After a quick search, I arrived at: http://msdn.microsoft.com/en-us/library/ee248630(v=vs.100).aspx
Installing was a breeze. However, in order to get the PowerShell Cmdlets, you have to do an advanced install and select it. It’s unchecked for whatever reason.
Alright! I have a new toy. Let’s fire it up and see get it to run. I start a scan.
Scan Type: Team Foundation Server Complete Health Check
Server URL: I select my TFS directory. Go.
Scan, scan, and scan. Five second scan completed. Wow, that was fast. Let’s see what’s going on.
Cannot validate the URL provided.
The scan was generated using the corrected URL “%TFSServerURLValidated%”.
After verifying my server URL. I have ruled out that this is just a bad error message.
Oh look, Other Reports.
Exception in TFS PowerShell Object Processor:
System.Management.Automation.PSArgumentException Incorrect Windows PowerShell version 3.0. Windows PowerShell version 2.0 is supported in the current console. at System.Management.Automation.Runspaces.MshConsoleInfo.AddPSSnapIn(String mshSnapInID) at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.DoAddPSSnapIn(String name, PSSnapInException& warning) at Microsoft.TeamFoundation.Diagnostics.PowerShellObjectProcessor.EnsureInitialized(String scriptRoot) at Microsoft.TeamFoundation.Diagnostics.PowerShellObjectProcessor.ProcessObject() System.Management.Automation Script
I see—we have PowerShell 3.0 installed, but it only likes 2.0. No problem!
A simple solution, we must navigate to our BPA install directory:
Mine was default: C:\Program Files (x86)\Microsoft Team Foundation Server 2013 Power Tools\Best Practices Analyzer
Create a new file: TfsBpa.exe.Config
The contents of this config file is as follows:
<?xml version ="1.0"?> <configuration> <startup> <supportedRuntime version="v4.0.30319"/> </startup> </configuration>
This will allow for our BPA to use the Common Language Runtime, CLR4, to be used.
Restart BPA if it’s open, then run another scan. Make sure your server URL is set because it’s unset every time you start the application.
About the Author
Sonny Nguyen has three years experience in the technology industry.
He is a currently a .NET Developer and System Administrator at BDCSoft.
His specialty lies within Troubleshooting and Problem Solving.
With outside the box thinking, he can approach problems in new, innovative ways.
His broad range of technical skills enables him to tackle any issue that may arise.