I'm trying to zip specific files however on some files powershell breaks due to the charachter limit of 256, I know I can can alter this y changing registry keys. But I kind of want to ignore this error and write it to a file and zip this error file into the created archive.
However it seems whenever I run this code and an errors appears it does not continue with the code but rather breaks it midway.
If anyone could help it would be much appriciated. Here is the code:
try { Add-Type -assembly "system.io.compression.filesystem";
[io.compression.zipfile]::CreateFromDirectory('C:\Windows\Temp\XYZ\directoryToZip',
'C:\zippedXYZ.zip')}
catch { Write-Output $_ | Out-File -Append -FilePath C:\Windows\Temp\XYZ\Error.txt;
Compress-Archive -Update C:\Windows\Temp\XYZ\Error.txt C:\zippedXYZ.zip}