I’m trying to zip a folder that contains some hidden files and folders. I noticed that Compress-Archive does not grab these so I thought I’d simply pass all the items.
Get-ChildItem C:\temp\test\* -Force |
Compress-Archive -DestinationPath c:\temp\tests1.zip -CompressionLevel NoCompression
This is met with a nasty error. It looks like Get-Item is failing to query the hidden files.
Get-Item : Could not find item C:\temp\test\New Text Document.txt. At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:814 char:63 + ... Entry.LastWriteTime = (Get-Item -LiteralPath $currentFilePath).LastWr ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\temp\test\New Text Document.txt:String) [Get-Item], IOException + FullyQualifiedErrorId : ItemNotFound,Microsoft.PowerShell.Commands.GetItemCommand Exception setting "LastWriteTime": "Cannot convert null to type "System.DateTimeOffset"." At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:814 char:25 + ... $currentArchiveEntry.LastWriteTime = (Get-Item -LiteralPa ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], SetValueInvocationException + FullyQualifiedErrorId : ExceptionWhenSetting
Testing confirmed Get-Item would also need the -Force parameter to query it. Is there a work around I’m not finding? Or should I just use 7zip or similar? I do not want to change the attributes just to zip them. If I zip them in Windows Explorer it zips them all just fine.
I appreciate any input.