TFS Power Tools 2008 Powershell Snapin won't r

2019-01-28 16:59发布

问题:

I've installed TFS Power Tools 2008 along with its PowerShell integration features on my Windows 2008 R2 developer machine.

When I try to run the following command to enable the snapin:

Add-PSSnapin Microsoft.TeamFoundation.PowerShell

in the 32-bit version of PowerShell.exe, under C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe it works fine. But when I try to do the same in the 64-bit version here: C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe I get the following error:

Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.TeamFoundation.PowerShell' is not installed on this machine.
At line:1 char:13
+ Add-PSSnapin <<<<  Microsoft.TeamFoundation.PowerShell
    + CategoryInfo          : InvalidArgument: (Microsoft.TeamFoundation.PowerShell:String) [Add-PSSnapin], PSArgument
   Exception
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

Any idea how to make it work in the 64-bit version? Thanks in advance.

回答1:

You got it backwards. The snapin is a 32-bit snapin. It works fine under PowerShell (x86) ie 32-bit but doesn't work under PowerShell (x64). Note: even though the folder is called SysWOW64 it isn't 64-bit. Under 64-bit Windows the native 64-bit binaries go in $env:SystemRoot\System32. The 32-bit binaries that run under Windows-on-Windows64 layer (ie they thunk from a 32-bit process and pointers to 64-bit OS calls) go in $env:SystemRoot\SysWOW64.



回答2:

Registry file for TFS Power Tools 2012:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.TeamFoundation.PowerShell]
"PowerShellVersion"="2.0"
"Vendor"="Microsoft Corporation"
"Description"="This is a PowerShell snap-in that includes the Team Foundation Server cmdlets."
"VendorIndirect"="Microsoft.TeamFoundation.PowerShell,Microsoft"
"DescriptionIndirect"="Microsoft.TeamFoundation.PowerShell,This is a PowerShell snap-in that includes the Team Foundation Server cmdlets."
"Version"="11.0.0.0"
"ApplicationBase"="C:\\Program Files (x86)\\Microsoft Team Foundation Server 2012 Power Tools"
"AssemblyName"="Microsoft.TeamFoundation.PowerTools.PowerShell, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
"ModuleName"="C:\\Program Files (x86)\\Microsoft Team Foundation Server 2012 Power Tools\\Microsoft.TeamFoundation.PowerTools.PowerShell.dll"
"CustomPSSnapInType"="Microsoft.TeamFoundation.PowerTools.PowerShell.TFPSSnapIn"


回答3:

Cathy Kong of Microsoft was kind enough to provide me with a workaround for this issue. The full details can be found here in the MSDN TFS PowerTools forum: http://social.msdn.microsoft.com/Forums/en-US/tfspowertools/thread/a116799a-0476-4c42-aa3e-45d8ba23739e/?prof=required

The fix is as follows and worked well for me:

Please save the following content and save it as *.reg file and import to Registry(just double click the *.reg file, click OK double)

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.TeamFoundation.PowerShell] "PowerShellVersion"="2.0" "Vendor"="Microsoft Corporation" "Description"="This is a PowerShell snap-in that includes the Team Foundation Server cmdlets." "VendorIndirect"="Microsoft.TeamFoundation.PowerShell,Microsoft" "DescriptionIndirect"="Microsoft.TeamFoundation.PowerShell,This is a PowerShell snap-in that includes the Team Foundation Server cmdlets." "Version"="10.0.0.0" "ApplicationBase"="C:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tools" "AssemblyName"="Microsoft.TeamFoundation.PowerTools.PowerShell, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" "ModuleName"="C:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tools\Microsoft.TeamFoundation.PowerTools.PowerShell.dll" "CustomPSSnapInType"="Microsoft.TeamFoundation.PowerTools.PowerShell.TFPSSnapIn"