提取 7zip 脚本在 Windows Server 2019 任务计划程序中不起作用

Extraction 7zip script doesn't work in Windows Server 2019 Task Scheduler

我创建了一个 ps1 脚本来提取一个 3Gb 的 zip 文件夹。每当我从 PowerShell ISE 运行 它时它都有效,但是当我将我的脚本添加到 windows 服务器 2019 任务调度程序时它只是说 运行ning 而它什么都不做。

我试过了

set-alias sz "$env:ProgramFiles-Zipz.exe"
Set-location C:\
sz x -oC:/ test.zip

我也试过了

setx path "%path%;C:\Program Files-Zip"
Set-location C:\
7z x test.zip -oc:\ -r

我希望提取 3gbs 文件夹。

我是这样解决的:

Add-Type -Assembly "System.IO.Compression.Filesystem"
[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\test.zip','C:\')

以及我创建任务计划程序的方式:

schtasks /create /tn "Extract" /sc onstart /delay 0000:30 /rl highest /ru system /tr "powershell.exe -file C:\scripts\setup\test.ps1"

提取一个 3GB 的文件夹用了 4 分钟。 我在这里找到了解决方案: https://ridicurious.com/2019/07/29/3-ways-to-unzip-compressed-files-using-powershell/