Private/New-CleanupReport.ps1

function New-CleanupReport {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$true)]
        [string] $Name
    )

    process {
        # Get disk space again and calculate difference
        $After        = Get-DiskSpace

        # Stop timer
        $Stopwatch.Stop()

        # Make data readable
        $TotalCleaned = "$(($After.FreeSpace - $Before.FreeSpace).ToString('00.00')) GB"
        $TotalRunTime = "$((($StopWatch.Elapsed).TotalSeconds).ToString('00.00')) sec"

        # Report
        if ($null -ne $script:CleanupReport) {
            $Report = [pscustomobject]@{
                Name    = $Name
                RunTime = $TotalRunTime
                Cleaned = $TotalCleaned
            }
            $script:CleanupReport.$($Name) = $Report
        }
        else {
            Write-Output "Total space cleaned: $TotalCleaned"
            Write-Output "Total run time : $TotalRunTime"
        }
    }
}