Need help with Powershell unzip using SYSTEM account from task scheduler

Welcome Forums General PowerShell Q&A Need help with Powershell unzip using SYSTEM account from task scheduler

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
3 years, 4 months ago.

  • Author
    Posts
  • #29686

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    Have you tried using the NETWORK SERVICE?

The topic ‘Need help with Powershell unzip using SYSTEM account from task scheduler’ is closed to new replies.