Clear-HTLogFiles.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function Clear-HTLogFiles {
    [CmdletBinding()]
    param (
        # Base path to remove logs below.
        [Parameter(Position=1)]
        [string]
        $BasePath = 'C:\Program Files\CSM'
        
    )

    process {
        $i = Read-Host -Prompt "All Log Files will be deleted, please confirm by typing 'c' and press enter "
        if($i -eq 'c')
        {
            Get-ChildItem -Path $BasePath -Filter *.log -Recurse | Remove-Item -Confirm:$false
            Write-Host "All Log Files under $BasePath is deleted"
        }else {
            Write-Host "No Files Deleted...."
        }

    }
    
}