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

Code before:
    else {
        if (![string]::IsNullOrEmpty($PublicFolderInfo.PublicFolder.ParentFolder)) {
            $ParentPublicFolderInfo=GetPublicFolderInfo($PublicFolderInfo.PublicFolder.ParentFolder)
            ValidateContentMBXUniqueness($ParentPublicFolderInfo)
            ValidateEntryIDMapping($ParentPublicFolderInfo)
            ValidateContentMBXQuota($ParentPublicFolderInfo)
            ValidateParentPublicFolder($ParentPublicFolderInfo)
        }
    }
}
function ValidateDumpsterFlag {
    param([PSCustomObject]$PublicFolderInfo)
    if ($PublicFolderInfo.PublicFolder.AdminFolderFlags -eq "DumpsterFolder") {
        $Issue="Public folder $($PublicFolderInfo.PublicFolder.Identity) is a dumpster folder, content folder and its dumpster are linked to each other, that link cannot be undone, in other words admins cannot delete dumpster only"
        $Fix="FIX --> Please move $($PublicFolderInfo.PublicFolder.Identity) public folder to be under NON_IPM_SUBTREE using Set-PublicFolder command, for more information please check https://aka.ms/setpf"
        WriteToScreenAndLog -Issue $Issue -Fix $Fix
        AskForFeedback
        QuitEXOSession
    }
}
function GetUserPermissions {
    param([PSCustomObject]$Perms)
    $WorkingPermissions=@("editor", "owner", "PublishingEditor", "DeleteAllItems")
    if ($null -ne $Perms) {
        foreach ($perm in $Perms.AccessRights) {
            if ($WorkingPermissions.Contains($($perm.ToLower()))) {
                return "user has permission"
            }
        }
        return "user has no permission"
    }

    else {
        return "user has no permission"
    }
}
function ValidateUserPermissions {
    param([PSCustomObject]$Perms, [PSCustomObject]$PermsUserPfMbx)
    if ($Perms.AccessRights.count -eq $PermsUserPfMbx.AccessRights.count) {
        foreach ($Perm in $perms.AccessRights) {
            if (!$PermsUserPfMbx.AccessRights.contains($Perm)) {
                return "sync issue exist"
            }
        }
        return "no sync issue exist"
    }
    return "sync issue exist"
}
function ValidatePublicFolderIssue {
    param([Parameter(Mandatory = $true)]
        [PSCustomObject]$PublicFolderInfo,

Review comment (security):
This will not work as expected. `Contains()` is case sensitive, so the list you have with `PublishingEditor` and `DeleteAllItems` will never be found because you removed the `.ToLower()`. 

Code after:
    else {
        if (![string]::IsNullOrEmpty($PublicFolderInfo.PublicFolder.ParentFolder)) {
            $ParentPublicFolderInfo=GetPublicFolderInfo($PublicFolderInfo.PublicFolder.ParentFolder)
            ValidateContentMBXUniqueness($ParentPublicFolderInfo)
            ValidateEntryIDMapping($ParentPublicFolderInfo)
            ValidateContentMBXQuota($ParentPublicFolderInfo)
            ValidateParentPublicFolder($ParentPublicFolderInfo)
        }
    }
}
function ValidateDumpsterFlag {
    param([PSCustomObject]$PublicFolderInfo)
    if ($PublicFolderInfo.PublicFolder.AdminFolderFlags -eq "DumpsterFolder") {
        $Issue="Public folder $($PublicFolderInfo.PublicFolder.Identity) is a dumpster folder, content folder and its dumpster are linked to each other, that link cannot be undone, in other words admins cannot delete dumpster only"
        $Fix="FIX --> Please move $($PublicFolderInfo.PublicFolder.Identity) public folder to be under NON_IPM_SUBTREE using Set-PublicFolder command, for more information please check https://aka.ms/setpf"
        WriteToScreenAndLog -Issue $Issue -Fix $Fix
        AskForFeedback
        QuitEXOSession
    }
}
function GetUserPermissions {
    param([PSCustomObject]$Perms)
    $WorkingPermissions=@("Editor", "Owner", "PublishingEditor", "DeleteAllItems").ToLower()
    if ($null -ne $Perms) {
        foreach ($perm in $Perms.AccessRights) {
            if ($WorkingPermissions.Contains($($perm.ToLower()))) {
                return "user has permission"
            }
        }
        return "user has no permission"
    }

    else {
        return "user has no permission"
    }
}
function ValidateUserPermissions {
    param([PSCustomObject]$Perms, [PSCustomObject]$PermsUserPfMbx)
    if ($Perms.AccessRights.count -eq $PermsUserPfMbx.AccessRights.count) {
        foreach ($Perm in $perms.AccessRights) {
            if (!$PermsUserPfMbx.AccessRights.contains($Perm)) {
                return "sync issue exist"
            }
        }
        return "no sync issue exist"
    }
    return "sync issue exist"
}
function ValidatePublicFolderIssue {
    param([Parameter(Mandatory = $true)]
        [PSCustomObject]$PublicFolderInfo,