forked from KelvinTegelaar/CIPP-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Soft Deleted Mailboxes Scripted Alert Added additional select-object to ListMailboxes to be used with the Soft Deleted Mailboxes Alert Added SetAuthMethod function to be used on the new Auth Methods page.
- Loading branch information
Showing
3 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
Modules/CIPPCore/Public/Alerts/Get-CIPPAlertSoftDeletedMailboxes.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function Get-CIPPAlertSoftDeletedMailboxes { | ||
<# | ||
.FUNCTIONALITY | ||
Entrypoint | ||
#> | ||
[CmdletBinding()] | ||
Param ( | ||
[Parameter(Mandatory = $false)] | ||
[Alias('input')] | ||
$InputValue, | ||
$TenantFilter | ||
) | ||
|
||
$Select = 'ExchangeGuid,ArchiveGuid,WhenSoftDeleted,UserPrincipalName,IsInactiveMailbox' | ||
|
||
try { | ||
$SoftDeletedMailBoxes = New-ExoRequest -tenantid $TenantFilter -cmdlet 'get-mailbox' -cmdParams @{SoftDeletedMailbox = $true} -Select $Select | Select-Object ExchangeGuid, ArchiveGuid, WhenSoftDeleted, @{ Name = 'UPN'; Expression = { $_.'UserPrincipalName' } }, IsInactiveMailbox | ||
|
||
# Filter out the mailboxes where IsInactiveMailbox is $true | ||
$AlertData = $SoftDeletedMailBoxes | Where-Object { $_.IsInactiveMailbox -ne $true } | ||
|
||
# Write the alert trace with the filtered data | ||
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData | ||
|
||
} catch { | ||
Write-AlertMessage -tenant $($TenantFilter) -message "Failed to check for soft deleted mailboxes in $($TenantFilter): $(Get-NormalizedError -message $_.Exception.message)" | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Administration/Invoke-SetAuthMethod.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function Invoke-SetAuthMethod { | ||
<# | ||
.FUNCTIONALITY | ||
Entrypoint | ||
.ROLE | ||
Tenant.Administration.ReadWrite | ||
#> | ||
Param( | ||
$Request, | ||
$TriggerMetadata | ||
) | ||
|
||
$APIName = "Set Authentication Policy" | ||
$state = if ($Request.Body.state -eq 'enabled') { $true } else { $false } | ||
$Tenantfilter = $Request.Body.TenantFilter | ||
|
||
try { | ||
Set-CIPPAuthenticationPolicy -Tenant $Tenantfilter -APIName $APIName -AuthenticationMethodId $($Request.Body.Id) -Enabled $state | ||
$StatusCode = [HttpStatusCode]::OK | ||
$SuccessMessage = "Authentication Policy for $($Request.Body.Id) has been set to $state" | ||
} catch { | ||
$ErrorMsg = Get-NormalizedError -message $($_.Exception.Message) | ||
$SuccessMessage = "Function Error: $($_.InvocationInfo.ScriptLineNumber) - $ErrorMsg" | ||
$StatusCode = [HttpStatusCode]::BadRequest | ||
} | ||
|
||
# Associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = $StatusCode | ||
Body = [pscustomobject]@{'Results' = "$SuccessMessage" } | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters