Functions/FileSizeAbove.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
filter FileSizeAbove {
<#
.SYNOPSIS
    To use as a filter against Get-ChildItem
.DESCRIPTION
    To use as a filter against Get-ChildItem
.PARAMETER Size
    The minimum size a file can be
.EXAMPLE
    Assume I have 1 large file in c:\temp, and many smaller files.
 
    dir c:\temp | FileSizeAbove -Size 1GB | Select-Object FullName, LastWriteTime, Length
 
    FullName LastWriteTime Length
    -------- ------------- ------
    C:\temp\install.wim 3/5/2020 11:39:23 AM 4314799742
.NOTES
    Could NOT make this an advanced function
#>



    param
    (
        [int] $Size
    )

    if ($_.Length -ge $Size) {
            $_
    }

}