3

我有一个 powershell 脚本 (.ps1),我告诉 TeamCity 运行它以部署一些应用程序。

问题是,当 TeamCity 执行脚本时,某些模块不可用。

Teamcity 正在从这里调用 powershell:

C:\Windows**SysWOW64**\WindowsPowerShell\v1.0\powershell.exe

但它应该从这里调用 powershell:

C:\Windows**System32**\WindowsPowerShell\v1.0\powershell.exe

无论哪种方式调用脚本,它仍然会在同一目录中查找模块,但由于某种原因,它在从 SysWOW64 调用时不起作用

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

PS C:\Users\Administrator.WTLDMZ> C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File C:\BuildScripts\ExampleFail.ps1 


    Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules


ModuleType Name                                ExportedCommands                
---------- ----                                ----------------                
Manifest   ADRMS                               {Update-ADRMS, Uninstall-ADRM...
Manifest   AppLocker                           {Set-AppLockerPolicy, Get-App...
Manifest   BestPractices                       {Get-BpaModel, Invoke-BpaMode...
Manifest   BitsTransfer                        {Add-BitsFile, Remove-BitsTra...
Manifest   CimCmdlets                          {Get-CimAssociatedInstance, G...
Script     ISE                                 {New-IseSnippet, Import-IseSn...
Manifest   Microsoft.PowerShell.Diagnostics    {Get-WinEvent, Get-Counter, I...
Manifest   Microsoft.PowerShell.Host           {Start-Transcript, Stop-Trans...
Manifest   Microsoft.PowerShell.Management     {Add-Content, Clear-Content, ...
Manifest   Microsoft.PowerShell.Security       {Get-Acl, Set-Acl, Get-PfxCer...
Manifest   Microsoft.PowerShell.Utility        {Format-List, Format-Custom, ...
Manifest   Microsoft.WSMan.Management          {Disable-WSManCredSSP, Enable...
Script     PSDiagnostics                       {Disable-PSTrace, Disable-PSW...
Binary     PSScheduledJob                      {New-JobTrigger, Add-JobTrigg...
Manifest   PSWorkflow                          {New-PSWorkflowExecutionOptio...
Manifest   PSWorkflowUtility                   Invoke-AsWorkflow               
Manifest   ServerManager                       {Get-WindowsFeature, Add-Wind...
Manifest   TroubleshootingPack                 {Get-TroubleshootingPack, Inv...
Manifest   WebAdministration                   {Start-WebCommitDelay, Stop-W...
Script     Wtl-Deploy                          {Wtl-Deploy-CheckDirectory, W...
Script     Wtl-F5                              {Add-F5.LTMPoolMember, Add-F5...
Script     Wtl-Remote                          {Wtl-Remote-DoRemotely, Wtl-R...

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe

PS C:\Users\Administrator.WTLDMZ> C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -File C:\BuildScripts\ExampleFail.ps1 


    Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules


ModuleType Name                                ExportedCommands                
---------- ----                                ----------------                
Manifest   BitsTransfer                        {Add-BitsFile, Remove-BitsTra...
Manifest   CimCmdlets                          {Get-CimAssociatedInstance, G...
Script     ISE                                 {New-IseSnippet, Import-IseSn...
Manifest   Microsoft.PowerShell.Diagnostics    {Get-WinEvent, Get-Counter, I...
Manifest   Microsoft.PowerShell.Host           {Start-Transcript, Stop-Trans...
Manifest   Microsoft.PowerShell.Management     {Add-Content, Clear-Content, ...
Manifest   Microsoft.PowerShell.Security       {Get-Acl, Set-Acl, Get-PfxCer...
Manifest   Microsoft.PowerShell.Utility        {Format-List, Format-Custom, ...
Manifest   Microsoft.WSMan.Management          {Disable-WSManCredSSP, Enable...
Script     PSDiagnostics                       {Disable-PSTrace, Disable-PSW...
Binary     PSScheduledJob                      {New-JobTrigger, Add-JobTrigg...
Manifest   TroubleshootingPack                 {Get-TroubleshootingPack, Inv...
Manifest   WebAdministration                   {Start-WebCommitDelay, Stop-W...
4

1 回答 1

6

我傻了:P

TeamCity 中有一个下拉菜单,您可以在其中选择 x86 或 x64 的运行模式。它设置为 x86。我将其更改为 x64。现在它在正确的版本下执行。

仍然很好奇为什么模块不会在 x86 中加载...

此外,SysWOW64 与 x86 相关,而 System32 与 x64 相关,这很奇怪

于 2013-06-26T21:18:16.907 回答