我創造了這個腳本來壓縮某個文件夾:壓縮 - 歸檔錯誤:不支持的格式
$timer = (Get-Date -Format yyy-MM-dd_HH-mm-ss)
$version = 1.1.2
$folder = New-Item -Name "test_$vesion_$timer" -ItemType directory
Copy-Item -Path test1\log -Destination $folder -Recurse
Compress-Archive -Path $folder -DestinationPath $folder
Remove-Item $folder -Recurse
但是當我嘗試它,我得到這個錯誤:
Compress-Archive : 1.1.2_2017-06-05_08-58-19 is not a supported archive file format. .zip is the only supported archive file format.
+ Compress-Archive -Path $folder -DestinationPath $folder
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (1.1.2_2017-06-05_08-58-19:String) [Compress-Archive], IOException
+ FullyQualifiedErrorId : NotSupportedArchiveFileExtension,Compress-Archive
你設置'$ version'但隨後使用'$ vesion'(缺少R)下一行,所以你的文件夾將不會被創建。 –