Turns on NTFS compression on a file/directory.
Enable-NtfsCompression [-Path] <String[]> [-Recurse] [-WhatIf] [-Confirm] [<CommonParameters>]
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.
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 . |
Enable-NtfsCompression -Path C:\Projects\Carbon
Turns on NTFS compression on and compresses the C:\Projects\Carbon
directory, but not its sub-directories.
Enable-NtfsCompression -Path C:\Projects\Carbon -Recurse
Turns on NTFS compression on and compresses the C:\Projects\Carbon
directory and all its sub-directories.
Get-ChildItem * | Where-Object { $_.PsIsContainer } | Enable-NtfsCompression
Demonstrates that you can pipe the path to compress into Enable-NtfsCompression
.