running Powershell script to unzip files doesn't work

Hi all,

I have been using Teamcity for a while and loving it.  This is my first attempt at using powershell really so bit new to some of its possible problems.  I have a script that will take an MVC package unzip the file and minify all the css and js files and rezip it.  This works perfectly on my machine and if I log onto the CI server with either admin account or our teamcity account (which the build server uses) I can run the script without a problem.

My issue is when I commit it into GIT and TeamCity pulls it down and runs it.  The script runs from start to finish giving out all the output expected, (no errors reported) but it will never unzip the file.  I have created a test ps1 file to ensure there was nothing around it causing an issue and still can not get it to work, here is the contents of 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 cant figure this one out.

Any and all advice would be great.

Thanks

Please sign in to leave a comment.