Need help with Powershell unzip using SYSTEM account from task scheduler

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Bob McCoy Bob McCoy 1 year, 10 months ago.

  • Author
  • #29686
    Profile photo of Windows LiveUser53
    Windows LiveUser53

    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..."}

  • #29697
    Profile photo of Bob McCoy
    Bob McCoy

    Have you tried using the NETWORK SERVICE?

You must be logged in to reply to this topic.