From 5f51c8ec0003284e978146bd3d417c82fe4ba4f2 Mon Sep 17 00:00:00 2001 From: Markus Gruber <26838358+GruberMarkus@users.noreply.github.com> Date: Sat, 16 Mar 2024 09:25:18 +0100 Subject: [PATCH] refactor: exchange connection logic --- src/Export-RecipientPermissions.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Export-RecipientPermissions.ps1 b/src/Export-RecipientPermissions.ps1 index a915925..fb5fb7a 100644 --- a/src/Export-RecipientPermissions.ps1 +++ b/src/Export-RecipientPermissions.ps1 @@ -982,7 +982,7 @@ try { try { # Get-EXORecipient does not (yet) return allowed RecipientTypeDetails, # so Get-Recipient is used for Exchange on-prem and Exchange Online - $null = $(. ([scriptblock]::Create($ConnectExchange)) -ScriptBlock { @( Get-Recipient -RecipientTypeDetails '!!!Fail!!!' -resultsize 1 -ErrorAction Stop -WarningAction silentlycontinue) }) + $null = . ([scriptblock]::Create("@(Get-$($CmdletPrefix)Recipient -RecipientTypeDetails '!!!Fail!!!' -resultsize 1 -ErrorAction Stop -WarningAction silentlycontinue)") } catch { $null = $error[0].exception -match '(?!.*: )(.*)(")$' $RecipientTypeDetailsListUnchecked = $matches[1].trim() -split ', ' | Where-Object { $_ } | Sort-Object -Unique