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'을 사용할 수있을 것으로 예상합니까? –