Public/Get-TheCleaners.ps1
|
function Get-TheCleaners { <# .EXTERNALHELP TheCleaners-help.xml #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Opt-in dedication, not pipeline data.')] [CmdletBinding()] [Alias('Start-Cleaning')] [OutputType('TheCleaners.CommandInfo')] param ( [Parameter()] [switch] $Dedication, [Parameter()] [switch] $NoLogo ) if ($Dedication) { Write-Host -Object 'Dedicated to the friends I spent years working with and learning PowerShell with. Cheers to Alex, Lyle, Jon, and Rick!' -ForegroundColor Yellow } if (-not $NoLogo) { Show-TheCleanersLogo } $Module = $ExecutionContext.SessionState.Module foreach ($Command in @($Module.ExportedFunctions.Values | Sort-Object -Property Name)) { $IsPreviewOnly = $Command.Name -in @('Clear-OldIISLog', 'Clear-OldExchangeLog') [pscustomobject]@{ PSTypeName = 'TheCleaners.CommandInfo' Name = $Command.Name Maturity = if ($IsPreviewOnly) { 'PreviewOnly' } else { 'Prerelease' } RemovalEnabled = $Command.Name -like 'Clear-*' -and -not $IsPreviewOnly SupportsWhatIf = $Command.Parameters.ContainsKey('WhatIf') } } } |