Need help with Powershell unzip using SYSTEM account from task scheduler

This topic contains 1 reply, has 2 voices, and was last updated by  Bob McCoy 2 years, 1 month ago.

  • Author
    Posts
  • #29686

    Windows LiveUser53
    Participant

    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())
    {
    $shell.Namespace($destination).copyhere($item,1564)
    "$($item.path) extracted"
    }
    }

    $hc_zip = $args[0]
    $hc_zip

    $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

    Bob McCoy
    Participant

    Have you tried using the NETWORK SERVICE?

You must be logged in to reply to this topic.