4

I have a powershell script (.ps1) that I am telling TeamCity to run in order to deploy some applications.

The problem is, when TeamCity executes the script, some Modules aren't available.

Teamcity is invoking powershell from here:

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

But it should be invoking powershell from here:

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

Either way the script is invoked, it still looks for modules in the same directory, but for some reason it doesn't work when invoked from 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...

1 Answer 1

6

I'm dumb :P

There is a dropdown in TeamCity where you can select the runmode of x86 or x64. It was set to x86. I changed it to x64. Now it executes under the correct version.

Still curious why the modules wouldn't load in x86 though...

Also, it's weird that SysWOW64 correlates to x86 and System32 correlates to x64

Sign up to request clarification or add additional context in comments.

2 Comments

SysWOW64 substitutes for System32 when 32 bit apps run on 64 bit Windows. This substitution is known as Windows on Windows (WOW). Similarly SysWOW32 was for 16 bit apps running on 32 bit Windows. \Windows\system32 started life as \windows\system on Win 3.1, Win95, and Win98. Win NT changed it to \windows\system32 (since NT was all 32 bit and Win95, etc. were mostly 16 bit). Programs written for Win NT and beyond expect certain files to be in the system32 folder. Since 64 bit Windows was designed to make porting 32 bit apps to 64 bit Windows easy System32 didn't change names.
That's not obvious. You're not dumb.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.