What is this scripting and how it is using .NET 4.5? Is it C# scripting? PowerShell Scripting? VBA Scripting?

I've found this answer in another question and was curious about it. As it's using .NET 4.5, I tried using the same methods in my .NET 4.7 solution and it wasn't available in Intellisense. Also I don't understand how you can call .NET 4.5 in that way from PowerShell and whey it would differ from the methods I get from my SDK?

The below code was submitted by @MDMarra

$Compression = [System.IO.Compression.CompressionLevel]::Optimal
$IncludeBaseDirectory = $false

$Source = "C:\Path\To\Source"
$Destination = "C:\CoolPowerShellZipFile.zip"


Does Windows have a built-in ZIP command for the command line?

2 Answers 2


powershell is [mostly] built on top of dotnet. it has many ways to access the underlying dotnet code, c# code, compiled DLL code, etc. the PoSh cmdlets are designed for easy use & readability. however, direct access to the guts of things is somewhat faster & may allow more control in some situations.

so, the process of doing so is made fairly easy. [grin]

as for file compression, yes, there is a cmdlet for that nowadays: Compress-Archive, which is a wrapper around the .NET class [System.IO.Compression.ZipArchive]. there was no such cmdlet early on, tho.

  • Awesome. Thanks I also found out that even though I was using the complete namespace to reach the class I still needed the 'using System.IO.Compression.FileSystem' to have the same CreateFromDirectory method available. Thanks for the clarification! Commented Apr 24, 2020 at 6:54
  • @DanielPaiva - you are most welcome! glad to know that you got things working as needed ... [grin]
    – Lee_Dailey
    Commented Apr 24, 2020 at 13:41

It seems to me as a powershell script that calls System.IO.Compression.FileSystem which is a C# class.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .