Skip to content

Commit

Permalink
Merge pull request #2189 from microsoft/bilong-removeinvalid
Browse files Browse the repository at this point in the history
Remove invalid permissions via pipe
  • Loading branch information
bill-long committed Sep 12, 2024
2 parents 3801c4c + 125cbbd commit bd69c9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions PublicFolders/SourceSideValidations/SourceSideValidations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ param (
. $PSScriptRoot\JobQueue.ps1
. $PSScriptRoot\..\..\Shared\ScriptUpdateFunctions\Test-ScriptVersion.ps1
. $PSScriptRoot\..\..\Shared\Out-Columns.ps1
. $PSScriptRoot\..\..\Shared\Confirm-ExchangeShell.ps1

# For HashSet support
Add-Type -AssemblyName System.Core -ErrorAction Stop
Expand Down Expand Up @@ -92,6 +93,15 @@ try {
}

if ($RemoveInvalidPermissions) {
$shell = Confirm-ExchangeShell

if (-not $shell.EMS) {
Write-Host "The -RemoveInvalidPermissions switch must be used from Exchange Management Shell. If you are using EMS,"
Write-Host "then there may be an issue with the Auth Certificate or some other issue preventing PowerShell serialization."
Write-Host "Cannot continue."
return
}

if (-not (Test-Path $ResultsFile)) {
Write-Error "File not found: $ResultsFile. Please specify -ResultsFile or run without -RemoveInvalidPermissions to generate a results file."
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function Remove-InvalidPermission {
) {
if ($PSCmdlet.ShouldProcess("$($result.FolderIdentity)", "Remove $($perm.User.DisplayName)")) {
Write-Host "Removing $($perm.User.DisplayName) from folder $($result.FolderIdentity)"
Remove-PublicFolderClientPermission $result.FolderEntryId -User $perm.User.DisplayName -Confirm:$false
$perm | Remove-PublicFolderClientPermission -Confirm:$false
}
}
}
Expand Down

0 comments on commit bd69c9c

Please sign in to comment.