PowerShell: Public Folder Search / remove



  • I have this script to SEARCH the public folders for a user

    $user = Read-Host "Enter an Exchange identity:  first.last"
    $distgroup = Get-DistributionGroup
    foreach ( $distgroup in $distgroup ) {
    
    $distmember = Get-DistributionGroupMember -Identity $($distgroup.identity) | where {$_.identity -eq "$user"}
    
        if ( $distmember -ne $null ) {
       Write-Host "$user is in $($distgroup.DisplayName)"
        }
    }
    Write-host "Search complete!"
    

    However, the next step is to remove that person from those public folders.

    I expect it's rather simple task,.. but the searches I have done, haven't found anything.



  • Is this what I am looking for?

    Remove-PublicFolderClientPermission -Identity "\My Public Folder" -User Contoso\Chris
    


  • @gjacobse said in PowerShell: Public Folder Search / remove:

    Is this what I am looking for?

    Remove-PublicFolderClientPermission -Identity "\My Public Folder" -User Contoso\Chris
    

    Looks correct to me.