Wie bekomme ich Compress-Archive
nur Unterordner Struktur komprimieren? Wie es jetzt ist, ist das Skript selbst in der .zip enthalten. Oder ist es möglich, das herauszufiltern?Compress-Archive in einem Skript angegeben enthält das Skript selbst
Der Code, den ich habe ist wie folgt:
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
}
Wie Sie verwenden 'Compress-Archive' in Powershell v2 erwarten zu können? –