Skip to content

Instantly share code, notes, and snippets.

@bill-long
Last active June 22, 2020 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bill-long/db11b0c962d89590b0c75eff1aa94785 to your computer and use it in GitHub Desktop.
Save bill-long/db11b0c962d89590b0c75eff1aa94785 to your computer and use it in GitHub Desktop.
function CheckFolderExists($folderToTest) {
$mbxs = Get-Mailbox -PublicFolder
Write-Output "Found $($mbxs.Count) public folder mailboxes"
$good = @()
$bad = @()
for ($i = 0; $i -lt $mbxs.Count; $i++) {
Write-Progress -Activity ($mbxs[$i].Identity) -PercentComplete ($i * 100 / $mbxs.Count)
$result = $null
$result = Get-PublicFolder $foldertoTest -Mailbox ($mbxs[$i].Identity) -ErrorAction SilentlyContinue
if ($null -ne $result) {
$good += $mbxs[$i].Identity.ToString()
}
else {
$bad += $mbxs[$i].Identity.ToString()
}
}
Write-Host "$($good.Count) mailboxes have it:"
$good | Sort
Write-Host "$($bad.Count) mailboxes don't have it."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment