Kelly Garcia
asked on
Find Files older than 6 months and then ZIP the Files
Hi All,
I have the script below:
how do I tell the script to find files only files that are equal to or greater than 1gb?
I have the script below:
$pathname = "C:\Users\kelly.garcia"
$files = Get-ChildItem $pathname -Recurse -File |
Where-Object LastAccessTime -le (Get-date).AddMonths(-1)
foreach ($f in $files)
{
$Name = $f.name
#Compress-Archive $f -DestinationPath $pathname\$Name.zip
}
how do I tell the script to find files only files that are equal to or greater than 1gb?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
for testing I want find files just over a 1mb how do I input that, do I just type 1mb where -ge 1gb is?
That's correct, yes.
ASKER
Compress-Archive : The path '2013-09-18 10.57.31.jpg' either does not exist or is not a valid file system path.
At line:4 char:1
+ Compress-Archive $f -DestinationPath $pathname\$Name.zip
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (2013-09-18 10.57.31.jpg:String) [Compress-Archive], InvalidOperationException
+ FullyQualifiedErrorId : ArchiveCmdletPathNotFound,
Open in new window