Im new to powershell and scripting.
I'm trying to compress IIS Log files (60GB total) using compress-archive cmdlet, however everytime I get the error:
"Exception of type 'System.OutOfMemoryException' was thrown."
I've already adjusted MaxMemoryPerShellMB to 2048MB and restarted the WinRM service.
RAM Memory consumption exceeds 6GB when the command is executed.
Code I'm using follows:
$exclude = Get-ChildItem -Path . | Sort-Object -Descending | Select-Object -First 1
$ArchiveContents = Get-ChildItem -Path . -Exclude $exclude | Sort-Object -Descending
Compress-Archive -Path $ArchiveContents -DestinationPath .\W3SVC2.zip -Force
Powershell version is 5. Can anyone guide me on this please?
Thanks in advance.