Reputation: 111
I have a folder that I want automatically compress with a script to make space. For that, I use the following script for a folder called 'test':
$a = Get-Item "D:\Aither\Pca\Test"
$a.Attributes += "Compressed"
After some tests, the attribute "hidden" works with the previous code but not with the attribute "Compressed"
Compress contents to save disk space should be checked. Even when turning off my computer, it's not working.
Did I make a mistake in my code or it's just a rights issue ?
Upvotes: 1
Views: 1334
Reputation: 24
Additionally to your answer -- there is a native command
Enable-NtfsCompression [-Path] <String[]> [-Recurse] [-WhatIf] [-Confirm] [<CommonParameters>]
Upvotes: 0
Reputation: 111
I found a answer with the following code :
Invoke-WmiMethod -Path "Win32_Directory.Name='D:\Aither\Pca\Test'" -Name compress
Upvotes: 1