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