Skip to content

Commit

Permalink
returned foreach
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Aug 9, 2023
1 parent 405d460 commit 41715e2
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions AddAlert/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,33 @@ $Results = foreach ($Tenant in $tenants) {
$URL = ($request.headers.'x-ms-original-url').split('/api') | Select-Object -First 1
if ($Tenant -eq 'AllTenants') {
Get-Tenants | ForEach-Object {
foreach ($eventype in $Request.body.EventTypes.value) {
foreach ($eventType in $Request.body.EventTypes.value) {
$params = @{
TenantFilter = $_.defaultDomainName
auditLogAPI = $true
operations = ($Request.body.Operations.value -join ',')
allowedLocations = ($Request.body.AllowedLocations.value -join ',')
BaseURL = $URL
EventType = $eventype
EventType = $eventType
ExecutingUser = $Request.headers.'x-ms-client-principal'
}
New-CIPPGraphSubscription @params
}
}
}
else {
$params = @{
TenantFilter = $tenant
auditLogAPI = $true
operations = ($Request.body.Operations.value -join ',')
allowedLocations = ($Request.body.AllowedLocations.value -join ',')
BaseURL = $URL
EventType = $eventype
ExecutingUser = $Request.headers.'x-ms-client-principal'
foreach ($eventType in $Request.body.EventTypes.value) {
$params = @{
TenantFilter = $tenant
auditLogAPI = $true
operations = ($Request.body.Operations.value -join ',')
allowedLocations = ($Request.body.AllowedLocations.value -join ',')
BaseURL = $URL
EventType = $eventType
ExecutingUser = $Request.headers.'x-ms-client-principal'
}
New-CIPPGraphSubscription @params
}
New-CIPPGraphSubscription @params
}
"Successfully added Alert for $($Tenant) to queue."
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Successfully added Alert for $($Tenant) to queue." -Sev 'Info'
Expand Down

0 comments on commit 41715e2

Please sign in to comment.