Unable to find type [System.IO.Compression.CompressionLevel]: make sure that the assembly containing this type is loaded
Try using Add-Type -AssemblyName System.IO.Compression.FileSystem
instead. It is cleaner and does not have a dependency on the reference assemblies which need an installation of Visual Studio.
You can manually add a .NET class to your PowerShell session.
Remove [Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem");
from your script and add the following at the very top:
Add-Type -Path "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.IO.Compression.FileSystem.dll"
Or on a 32-bit box:
Add-Type -Path "C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.IO.Compression.FileSystem.dll"
This presumes .NET 4.5 installed OK on your system and System.IO.Compression.FileSystem.dll
actually exists.