'How to enable / disable web application compression via command line?

I'm running iis 10 on windows server 2016. I need to enable content compression for some web application and disable it for others. These check boxes specifically. iis content compression
(source: customerscanvas.com)

Is there a way to do it via command line? preferably via powershell / appcmd.



Solution 1:[1]

You could enable and disable compression for site using below command:

appcmd set config "site1" /section:urlCompression /doDynamicCompression:True

appcmd set config "urlsample" /section:urlCompression /doStaticCompression:True

Result:

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brando Zhang