Enable-NtfsCompression

Turns on NTFS compression on a file/directory.

Syntax

Enable-NtfsCompression [-Path] <String[]> [-Recurse] [-WhatIf] [-Confirm] [<CommonParameters>]

Description

By default, when enabling compression on a directory, only new files/directories created after enabling compression will be compressed. To compress everything, use the -Recurse switch.

Uses Windows' compact.exe command line utility to compress the file/directory. To see the output from compact.exe, set the Verbose switch.

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
Path String[]

The path where compression should be enabled.

true true (ByValue, ByPropertyName)
Recurse SwitchParameter

Enables compression on all sub-directories.

false false False
WhatIf SwitchParameter false false
Confirm SwitchParameter false false
CommonParameters This cmdlet supports common parameters. For more information type
Get-Help about_CommonParameters.

EXAMPLE 1

Enable-NtfsCompression -Path C:\Projects\Carbon

Turns on NTFS compression on and compresses the C:\Projects\Carbon directory, but not its sub-directories.

EXAMPLE 2

Enable-NtfsCompression -Path C:\Projects\Carbon -Recurse

Turns on NTFS compression on and compresses the C:\Projects\Carbon directory and all its sub-directories.

EXAMPLE 3

Get-ChildItem * | Where-Object { $_.PsIsContainer } | Enable-NtfsCompression

Demonstrates that you can pipe the path to compress into Enable-NtfsCompression.