Ensure usage Powershell (x86) for TFPT Powershell Cmdlets

Hi FB,

The Visual Studio Team Foundation Server 2010 Power Tools offers a feature that provides some helpful cmdlets in Powershell. However, it's a known fact that these cmdlets only work in the x86 Powershell host. When attempting to add the snapin in an x64 host, an error is returned that claims the snapin is not installed, when it clearly is.

I see this error in FinalBuilder when trying to use powershell actions because the powershell options provide for only one executable path, and it appears to always be the executable located under %SYSTEMROOT%\System32\. This is fine for x86 machines, in which case that's the only one; however, on x64 machines the x86 executable is located under %SYSTEMROOT%\SysWOW64\ instead.

Ultimately I think the most appropriate solution to this problem is to expose both Powershell (x86) actions as well as Powershell actions, just as the same differentiation between executables is available in Windows. Accordingly both paths would be specified in options. However, in the meantime, I'm looking for a workaround to get through this.

My first idea is to insert a Run Script action that simply runs Test-Path on the SysWOW64 path for powershell, and upon finding it changes the FinalBuilder Powershell Location option to that path instead. That way, subsequent usages of powershell actions will use the correct version of Powershell. From inside the powershell environment inside a Run Script action, however, I can find only $FBVariables, and no API that exposes the GetOptionObject function.

How do I change option objects with Powershell?

Hi

We’re still trying to figure out how best to deal with this in a way that maintains backwards compatibility. What you can do however is set the options from the BeforeAction script event using javascript :
[Code]var opt = GetOptionsObject(“Windows PowerShell”);if (opt){ opt.Properties.PropertyAsString(“PowershellLocation”) = “c:\windows\SysWow64\windowspowershell\v1.0\powershell.exe”;}[/Code]

This will change the options for the Execute Powershell script only. For the Script events (ie BeforeAction/AfterAction), when using Powershell we load the powershell assemblies directly, since FB is a 32bit application my guess is it 32bit it should work as expected so you may not need to use the powershell action, you could just try the Run Script Action and set the Script language to PowerShell.