在远程服务器上压缩文件很慢,有人可以检查我的 PS

Zip a file on remote server slow, can someone check my PS

这里很新,有人会检查我的 PS 看看我是否以最佳速率压缩 2 个文件吗? 当我通过 mstsc 登录时需要几秒钟,但这样做真的很慢(在下面的例子中,文件很小,但我想用 2 个文件压缩大约 600mb):

$compress = @{
  
  Path = "\servername\c$\Users\Public\Documents.txt", "\servername\c$\Users\Public\Documents.txt"
  CompressionLevel = "Fastest"
  DestinationPath = "\Servername\c$\temp.zip"}
Compress-Archive @compress

使用 Invoke-Command 在远程服务器上执行 Compress-Archive (与您描述的使用 RDP 的方式相同):

Invoke-Command -ComputerName Servername {
    $compress = @{
        Path = 'C:\Users\Public\Documents.txt','C:\Users\Public\Documents.txt'
        CompressionLevel = 'Fastest'
        DestinationPath = 'C:\temp.zip'
    }
    Compress-Archive @compress
}