Repository: microsoft/CSS-Exchange
File: PublicFolders/ValidateEXOPFDumpster.ps1 (PowerShell)

Code before:
function ValidateDumpsterChildren {
    param([PSCustomObject]$PublicFolderInfo)
    try {
        $HasChildren= Get-PublicFolder $PublicFolderInfo.PublicFolderDumpster.EntryId -ErrorAction stop -GetChildren
        $CurrentDescription = "Validating if dumpster folder:$($PublicFolderInfo.PublicFolderDumpster.EntryId) has children"
        $CurrentStatus = "Success"
        LogError -Function "Validate if dumpster folder has children" -CurrentStatus $CurrentStatus -CurrentDescription $CurrentDescription
    } catch {
        $ErrorEncountered=$Global:error[0].Exception
        $CurrentDescription = "Validating if dumpster folder:$($PublicFolderInfo.PublicFolderDumpster.EntryId) has children"
        $CurrentStatus = "Failure with error: "+$ErrorEncountered
        LogError -Function "Validate if dumpster folder has children" -CurrentStatus $CurrentStatus -CurrentDescription $CurrentDescription
        Write-Host "Error encountered during executing the script!"-ForegroundColor Red
        Write-Host $ErrorEncountered -ForegroundColor Red
        Write-Host "`nOutput was exported in the following location: $ExportPath" -ForegroundColor Yellow
        Start-Sleep -Seconds 3
        break
    }
    if ($null -ne $HasChildren) {
        $Fix= "FIX --> Please follow the following article https://aka.ms/setpf to move $($PublicFolderInfo.PublicFolder.Identity) dumpster children found to under NON_IPM_SUBTREE scope e.g. \NON_IPM_SUBTREE\DUMPSTER_ROOT\DUMPSTER_EXTEND\RESERVED_1\RESERVED_1"
        $Issue="Public folder $($PublicFolderInfo.PublicFolder.Identity) dumpster has $($HasChildren.Name.count) subfolder(s) which is a blocker for deletion operations over the public folder!`nDumpster subfolder(s) found:`n----------------------------`n$($HasChildren.identity)"
        WriteToScreenAndLog -Issue $Issue -Fix $Fix
    }
}
function ValidateMePfGuid {
    param([PSCustomObject]$PublicFolderInfo)
    #validate if MailRecipientGuid parameter is found empty/null
    if ($PublicFolderInfo.PublicFolder.MailEnabled -eq $true) {
        $HasValue=$PublicFolderInfo.PublicFolder.MailRecipientGuid.Guid
        if ($null -eq $HasValue -or $HasValue -eq "00000000-0000-0000-0000-000000000000") {
            $Fix= "FIX --> Please follow the following article https://aka.ms/EnableMPF to mail enable the affected public folder to generate a GUID over MailRecipientGuid parameter, validate MailRecipientGuid parameter has a GUID using https://aka.ms/getpf article then mail disable the affected public folder back again using https://aka.ms/disablempf article to be able to remove the public folder as requested."
            $Issue="Mail-enabled public folder $($PublicFolderInfo.PublicFolder.Identity) is unhealthy e.g MailRecipientGuid parameter is found empty/null which is a blocker for deletion operations over the public folder"
            WriteToScreenAndLog -Issue $Issue -Fix $Fix
        }
    }
}
function ExtractLog {
    param([PSCustomObject]$PublicFolderInfo)
    #create zip file for logs folder
    if (!(Test-Path  "$ExportPath\logs_$ts")) {
        mkdir "$ExportPath\logs_$ts" -Force | Out-Null
    }
    $PublicFolderInfo | Export-Clixml -Path "$ExportPath\logs_$ts\PublicFolderInfo$($PublicFolderInfo.PublicFolder.Name).xml"
}
function AskForFeedback {
    Write-Host "Please rate the script experience & tell us what you liked or what we can do better over https://aka.ms/PFDumpsterFeedback!" -ForegroundColor Cyan
    "Please rate the script experience & tell us what you liked or what we can do better over https://aka.ms/PFDumpsterFeedback!" | Out-File $ExportPath\$Script:ReportName -Append
}
function QuitEXOSession {
    if ($null -eq $SessionCheck) {
        try {

Review comment (suggestion):
You should probably comment here that `Me` stands for Mail Enabled public folder. This makes it easier for a reader of the code to understand what this is. 

Code after:
function ValidateDumpsterChildren {
    param([PSCustomObject]$PublicFolderInfo)
    try {
        $HasChildren= Get-PublicFolder $PublicFolderInfo.PublicFolderDumpster.EntryId -ErrorAction stop -GetChildren
        $CurrentDescription = "Validating if dumpster folder:$($PublicFolderInfo.PublicFolderDumpster.EntryId) has children"
        $CurrentStatus = "Success"
        LogError -Function "Validate if dumpster folder has children" -CurrentStatus $CurrentStatus -CurrentDescription $CurrentDescription
    } catch {
        $ErrorEncountered=$Global:error[0].Exception
        $CurrentDescription = "Validating if dumpster folder:$($PublicFolderInfo.PublicFolderDumpster.EntryId) has children"
        $CurrentStatus = "Failure with error: "+$ErrorEncountered
        LogError -Function "Validate if dumpster folder has children" -CurrentStatus $CurrentStatus -CurrentDescription $CurrentDescription
        Write-Host "Error encountered during executing the script!"-ForegroundColor Red
        Write-Host $ErrorEncountered -ForegroundColor Red
        Write-Host "`nOutput was exported in the following location: $ExportPath" -ForegroundColor Yellow
        Start-Sleep -Seconds 3
        break
    }
    if ($null -ne $HasChildren) {
        $Fix= "FIX --> Please follow the following article https://aka.ms/setpf to move $($PublicFolderInfo.PublicFolder.Identity) dumpster children found to under NON_IPM_SUBTREE scope e.g. \NON_IPM_SUBTREE\DUMPSTER_ROOT\DUMPSTER_EXTEND\RESERVED_1\RESERVED_1"
        $Issue="Public folder $($PublicFolderInfo.PublicFolder.Identity) dumpster has $($HasChildren.Name.count) subfolder(s) which is a blocker for deletion operations over the public folder!`nDumpster subfolder(s) found:`n----------------------------`n$($HasChildren.identity)"
        WriteToScreenAndLog -Issue $Issue -Fix $Fix
    }
}
#MePf=Mail Enabled Public Folder
function ValidateMePfGuid {
    param([PSCustomObject]$PublicFolderInfo)
    #validate if MailRecipientGuid parameter is found empty/null
    if ($PublicFolderInfo.PublicFolder.MailEnabled -eq $true) {
        $HasValue=$PublicFolderInfo.PublicFolder.MailRecipientGuid.Guid
        if ($null -eq $HasValue -or $HasValue -eq "00000000-0000-0000-0000-000000000000") {
            $Fix= "FIX --> Please follow the following article https://aka.ms/EnableMPF to mail enable the affected public folder to generate a GUID over MailRecipientGuid parameter, validate MailRecipientGuid parameter has a GUID using https://aka.ms/getpf article then mail disable the affected public folder back again using https://aka.ms/disablempf article to be able to remove the public folder as requested."
            $Issue="Mail-enabled public folder $($PublicFolderInfo.PublicFolder.Identity) is unhealthy e.g MailRecipientGuid parameter is found empty/null which is a blocker for deletion operations over the public folder"
            WriteToScreenAndLog -Issue $Issue -Fix $Fix
        }
    }
}
function ExtractLog {
    param([PSCustomObject]$PublicFolderInfo)
    #create zip file for logs folder
    if (!(Test-Path  "$ExportPath\logs_$ts")) {
        mkdir "$ExportPath\logs_$ts" -Force | Out-Null
    }
    $PublicFolderInfo | Export-Clixml -Path "$ExportPath\logs_$ts\PublicFolderInfo$($PublicFolderInfo.PublicFolder.Name).xml"
}
function AskForFeedback {
    $Feedback="Please rate the script experience & tell us what you liked or what we can do better over https://aka.ms/PFDumpsterFeedback!"
    Write-Host $Feedback -ForegroundColor Cyan
    $Feedback | Out-File $ExportPath\$Script:ReportName -Append
}
function QuitEXOSession {