Functions/Test-Switch.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Function Test-Switch
{
    [CmdletBinding()]
    param(
        [Parameter(HelpMessage='What path would you like to target?')]
        [Alias('Target')]
        [string[]]$Path,

        [switch]$Recurse
    )
    switch ($Recurse.IsPresent) {
        $True {
            Write-Verbose "Recursing" -Verbose
            Get-ChildItem -Path $Path -File -Recurse
        }
        $False {
            Write-Verbose "NOT Recursing" -Verbose
            Get-ChildItem -Path $Path -File
        }
    }
}