Author Posts

September 11, 2015 at 5:27 am

I run multiple powershell scripts from task scheduler using the SYSTEM account. This is the only script that does not work. This script needs a Windows user account defined in task scheduler to run. Is there a way to get this script to work using the SYSTEM account? If not, is there another way to unzip files using powershell that does not have this requirement? Below is the code:

function Expand-ZIPFile
param($file, $destination)
$shell = new-object -com shell.application
$zip = $shell.NameSpace($file)
foreach($item in $zip.items())
"$($item.path) extracted"

$hc_zip = $args[0]

$hc_dest = $args[1]

if (Test-Path $hc_zip){Expand-ZIPFile –File “$hc_zip” –Destination "$hc_dest”}
else{Write-Output "Zip file does not exist..."}

September 11, 2015 at 9:56 am

Have you tried using the NETWORK SERVICE?