I have a deployment agent on a machine implemented as a windows service. Service is 32-bit and runs on windows server 2008R2 x64 SP1 with powershell V2. Powershell script requires elevation and to run under x64 because of dependency to powershell module 'IIS Administration'. To achieve this, the service starts a cmd file which in turn launches powershell x64 console:
C:\WINDOWS\sysnative\WindowsPowerShell\v1.0\powershell.exe "Start-Process C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell -ArgumentList '-ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File C:\Temp\EndJobCmd\Install.ps1' -Verb RunAs"
This seems to work well. The problem I have is that the script has a sequence where it unpacks a zip file to a destination folder using shell.application, this works fine when triggered manually on the server or through the task scheduler, but when triggered from the service it does not extract any files at all (cannot see any errors thrown by the script but it seems to continue to execute as it logs a successful message to the event log after finishing).
Unzip sequence looks like:
$shell = New-Object -com shell.application $pkg = $shell.namespace($sourceFile) $installDir = $shell.namespace($targetDir) $installDir.Copyhere($pkg.items(), 20)Any advice greatly appreciated. I have searched some and seen a few people with similar issue but have yet to find a solution.