I have a script that unzips an MVC package, minifies all the CSS and js files, and rezips it. It works perfectly on my machine and on the CI server as an admin or the TeamCity account. When TeamCity pulls it down and runs it, the script gives all the output expected, doesn't report an error, but it will never unzip the file.
write-host "creating shell object"
$shell_app=new-object -com shell.application
write-host "creating zip file"
$zip_file = $shell_app.namespace("C:\temp\PokerLeagueWebSite.zip")
write-host "setting folder to unzip to"
$destination = $shell_app.namespace("C:\temp\zy98")
write-host "about to copy files from zip"
$destination.Copyhere($zip_file.items(), 0x4)
write-host "finished"
Here is the output from TeamCity:
[23:01:03]: Step 5/5: test ps1 file (Powershell)
[23:01:03]: [Step 5/5] Starting: C:\Windows\system32\cmd.exe /c
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -File
C:\TeamCity\buildAgent\work\71e78d4c543e0594\Tools\test.ps1 && exit /b %ERRORLEVEL%
[23:01:03]: [Step 5/5] in directory: C:\TeamCity\buildAgent\work\71e78d4c543e0594
[23:01:03]: [Step 5/5] creating shell object
[23:01:03]: [Step 5/5] creating zip file
[23:01:03]: [Step 5/5] setting folder to unzip to
[23:01:03]: [Step 5/5] about to copy files from zip
[23:01:03]: [Step 5/5] finished
[23:01:03]: [Step 5/5] Process exited with code 0
[23:01:03]: Publishing internal artifacts
[23:01:03]: [Publishing internal artifacts] Sending build.finish.properties.gz file
[23:01:03]: Build finished
If I run the exact command on the server on the TeamCity account it works correctly:
C:\Windows\system32\cmd.exe /c C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -File C:\TeamCity\buildAgent\work\71e78d4c543e0594\Tools\test.ps1 && exit /b %ERRORLEVEL%
I can only think it is either something TeamCity is doing or something related to the fact it is running as a service, but I am stumped and can't figure this one out.