我需要在一个新文件夹中创建一个压缩文件,但是powershell compress-archive destinationpath不强制创建文件夹。
我的目标在一个变量中。
$Composant = "foo.bar/foo.bar.ImportMe"我的powershel代码是:
compress-archive -Path $outdirbuild/$Composant/* -DestinationPath "temp/OutilDeploiement/$($Composant).zip" -compressionlevel optimal -verbose我的错误是:
Abandon : The path 'temp\OutilDeploiement\foo.bar' either does not exist or is not a valid file system path.发布于 2021-07-08 21:29:37
这应该行得通,如果不行,请告诉我:
$source = Join-Path $outdirbuild -ChildPath $Composant\*
$destination = 'absolutepath\to\zipfolder'
$fileName = 'zipfile.zip'
if(-not(Test-Path $destination))
{
New-Item -Path $destination -ItemType Directory -Force > $null
}
$params = @{
Path = $source
DestinationPath = Join-Path $destination -ChildPath $fileName
CompressionLevel = 'Optimal'
Verbose = $true
}
Compress-Archive @params\*的情况下添加要压缩的\*在源路径的末尾您没有压缩根文件夹,只需确认这是否是您想要的。https://stackoverflow.com/questions/68301950
复制相似问题