Use Appcmd to set IIS compression level

Tags: IIS, powershell, compression

Here are a few commands to set properties on IIS compression.   

'This was run from cmd.exe
c:\windows\system32\inetsrv\appcmd set config -section:urlCompression /doDynamicCompression:true
c:\windows\system32\inetsrv\appcmd set config -section:system.webServer/httpCompression -[name='gzip'].dynamicCompressionLevel:9
c:\windows\system32\inetsrv\appcmd set config /section:httpCompression -directory:E:\Data\IISTemporaryCompressedFiles -maxDiskSpaceUsage:100 -minFileSizeForComp:256
icacls E:\Data\IISTemporaryCompressedFiles /grant "NT Authority\Authenticated Users:(OI)(CI)(M)"

This was run from Powershell.  Note the slight syntax difference.
c:\windows\system32\inetsrv\appcmd set config /section:urlCompression /doDynamicCompression:true
c:\windows\system32\inetsrv\appcmd set config /section:system.webServer/httpCompression -[name="'gzip'"].dynamicCompressionLevel:9
c:\windows\system32\inetsrv\appcmd set config /section:httpCompression /directory:E:\Data\IISTemporaryCompressedFiles /maxDiskSpaceUsage:100 /minFileSizeForComp:256
icacls E:\Data\IISTemporaryCompressedFiles /grant "NT Authority\Authenticated Users:(OI)(CI)(M)"

Properties on the httpCompression section
ERROR ( message:-sendCacheHeaders
-expiresHeader
-cacheControlHeader
-directory
-doDiskSpaceLimiting
-maxDiskSpaceUsage
-minFileSizeForComp
-noCompressionForHttp10
-noCompressionForProxies
-noCompressionForRange
-staticCompressionDisableCpuUsage
-staticCompressionEnableCpuUsage
-dynamicCompressionDisableCpuUsage
-dynamicCompressionEnableCpuUsage
-staticTypes.[mimeType='string'].mimeType
-staticTypes.[mimeType='string'].enabled
-dynamicTypes.[mimeType='string'].mimeType
-dynamicTypes.[mimeType='string'].enabled
-[name='string'].name
-[name='string'].doStaticCompression
-[name='string'].doDynamicCompression
-[name='string'].dll
-[name='string'].staticCompressionLevel
-[name='string'].dynamicCompressionLevel
 )

Side note.  I ran into some 'slight' syntax issues when running appcmd in Powershell 1.0.  I needed to change the dashes "-" to slashes "/".   I suppose we'll look at using the Powershell provider one day,

3 Comments

Add a Comment