我有一个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...

最佳答案

我很傻:P

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

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

另外,SysWOW64与x86相关联而System32与x64相关联也很奇怪

10-06 06:15