Compress-Archive
にサブフォルダ構造のみを圧縮するにはどうすればよいですか?今のように、スクリプトそのものは.zipに含まれています。または、それをフィルタリングすることは可能ですか?次のようにスクリプト内の圧縮アーカイブにはスクリプト自体が含まれています
私が得たコードは次のとおりです。
if (!($PSScriptRoot)) { Split-Path $MyInvocation.MyCommand.Path -Parent }
$destination = Split-Path $MyInvocation.MyCommand.Path -Parent
$source = (Get-ChildItem $PSScriptRoot)
$date = Get-Date -UFormat "%Y-%m-%d"
$zipfile = $destination + "\createdOn" + $date + ".zip"
#Check if file exists
if ([System.IO.File]::Exists($zipfile))
{
Clear-Host
Write-Host "File created: " $zipfile
Compress-Archive -DestinationPath $zipfile -Force -Path $source -CompressionLevel Optimal
}
else
{
Clear-Host
Write-Host "File created: " $zipfile
Compress-Archive -DestinationPath $zipfile -Force -Path $source -CompressionLevel Optimal
}
あなたはPowerShellのv2の中で '圧縮-Archive'を使用できることを期待するにはどうすればよいですか? –