我有一个powershell脚本(.ps1),我告诉TeamCity要运行以部署一些应用程序。
问题是,当TeamCity执行脚本时,某些模块不可用。
Teamcity从这里调用powershell:
C:\视窗** ** SysWOW64中\ WindowsPowerShell \ V1.0 \ powershell.exe
但它应该从这里调用powershell:
C:\视窗** ** 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...
答案 0 :(得分:6)
我很笨:P
TeamCity中有一个下拉列表,您可以在其中选择x86或x64的运行模式。它被设置为x86。我把它改成了x64。现在它在正确的版本下执行。
仍然好奇为什么模块不会在x86中加载...
另外,SysWOW64与x86相关并且System32与x64相关,这很奇怪