I am writing a powershell script to run on a windows server 2008-r2 box running powershell v2, and it requires the ability to zip files. To do that, I need to have this line of code to import the assembly:
add-type -path "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.IO.Compression.FileSystem.dll"
However, when I run the code, it errors with:
Add-Type : Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.IO.Compressi
on.FileSystem.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runt
ime and cannot be loaded.
So I went to check what .NET version is installed using the registry method provided here: Microsoft: How to determine which .NET Framework versions are installed
And sure enough I am on
378758 == .NET Framework 4.5.1 installed on Windows 8, Windows 7 SP1, or Windows Vista SP2
And it even shows the install path as:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319
Does anyone know what may be the issue here? Or what I can do as a workaround (Without software updates/installs).