I have a problem in that my PowerShell Archive archive script crashes after consuming my entire machines memory using the Compress-Archive cmdlet. The for loop added below really helped by only dealing with a few files at a time, but I am still getting "Out of Memory" errors on my large files I am trying to compress.
Is setting max PowerShell memory still an option? I understand set max memory may not work. Also, I see garbage collection can be a solution. Where would one place the garbage collection and what would the appropriate syntax be?
Text
[System.GC]::Collect()
Text
$ArchiveContents = Get-ChildItem -Path C:\OneDrive | Sort-Object -Descending for ($i=0; $i -le $ArchiveContents.Count; $i=$i+10) { Compress-Archive -Path $ArchiveContents.FullName[$i..($i+9)] -Update -DestinationPath \\Server011\Backup_Archive\CompanyData\Daily...