Skip to content

Commit 7c7d0a6

Browse files
authored
Merge pull request #548 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 8e112b3 + 3ae9bd2 commit 7c7d0a6

File tree

5 files changed

+66
-20
lines changed

5 files changed

+66
-20
lines changed

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Standards/Push-CIPPStandard.ps1

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,32 @@ function Push-CIPPStandard {
1212
$Standard = $Item.Standard
1313
$FunctionName = 'Invoke-CIPPStandard{0}' -f $Standard
1414
Write-Information "We'll be running $FunctionName"
15-
$Rerun = Test-CIPPRerun -Type Standard -Tenant $Tenant -API "$($Standard)_$($Item.templateId)"
15+
16+
if ($Standard -in @('IntuneTemplate', 'ConditionalAccessTemplate')) {
17+
$API = "$Standard_$($Item.templateId)_$($Item.Settings.TemplateList.value)"
18+
} else {
19+
$API = "$Standard_$($Item.templateId)"
20+
}
21+
22+
$Rerun = Test-CIPPRerun -Type Standard -Tenant $Tenant -API $API
1623
if ($Rerun) {
1724
Write-Information 'Detected rerun. Exiting cleanly'
1825
exit 0
1926
} else {
2027
Write-Information "Rerun is set to false. We'll be running $FunctionName"
2128
}
29+
30+
$script:StandardInfo = @{
31+
Standard = $Standard
32+
StandardTemplateId = $Item.templateId
33+
}
34+
if ($Standard -eq 'IntuneTemplate') {
35+
$script:StandardInfo.IntuneTemplateId = $Item.Settings.TemplateList.value
36+
}
37+
if ($Standard -eq 'ConditionalAccessTemplate') {
38+
$script:StandardInfo.ConditionalAccessTemplateId = $Item.Settings.TemplateList.value
39+
}
40+
2241
try {
2342
# Convert settings to JSON, replace %variables%, then convert back to object
2443
$SettingsJSON = $Item.Settings | ConvertTo-Json -Depth 10 -Compress
Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Function Invoke-ListExtensionsConfig {
1+
function Invoke-ListExtensionsConfig {
22
<#
33
.FUNCTIONALITY
44
Entrypoint,AnyTenant
@@ -9,27 +9,32 @@ Function Invoke-ListExtensionsConfig {
99
param($Request, $TriggerMetadata)
1010
$Table = Get-CIPPTable -TableName Extensionsconfig
1111
try {
12-
$Body = (Get-CIPPAzDataTableEntity @Table).config | ConvertFrom-Json -Depth 10 -ErrorAction Stop
13-
if ($Body.HaloPSA.TicketType -and !$Body.HaloPSA.TicketType.value) {
14-
# translate ticket type to autocomplete format
15-
Write-Information "Ticket Type: $($Body.HaloPSA.TicketType)"
16-
$Types = Get-HaloTicketType
17-
$Type = $Types | Where-Object { $_.id -eq $Body.HaloPSA.TicketType }
18-
#Write-Information ($Type | ConvertTo-Json)
19-
if ($Type) {
20-
$Body.HaloPSA.TicketType = @{
21-
label = $Type.name
22-
value = $Type.id
12+
$Config = (Get-CIPPAzDataTableEntity @Table).config
13+
if (Test-Json -Json $Config) {
14+
$Body = $Config | ConvertFrom-Json -Depth 10 -ErrorAction Stop
15+
if ($Body.HaloPSA.TicketType -and !$Body.HaloPSA.TicketType.value) {
16+
# translate ticket type to autocomplete format
17+
Write-Information "Ticket Type: $($Body.HaloPSA.TicketType)"
18+
$Types = Get-HaloTicketType
19+
$Type = $Types | Where-Object { $_.id -eq $Body.HaloPSA.TicketType }
20+
#Write-Information ($Type | ConvertTo-Json)
21+
if ($Type) {
22+
$Body.HaloPSA.TicketType = @{
23+
label = $Type.name
24+
value = $Type.id
25+
}
2326
}
2427
}
28+
} else {
29+
$Body = @{}
2530
}
2631
} catch {
2732
Write-Information (Get-CippException -Exception $_ | ConvertTo-Json)
2833
$Body = @{}
2934
}
3035
return [HttpResponseContext]@{
31-
StatusCode = [HttpStatusCode]::OK
32-
Body = $body
33-
}
36+
StatusCode = [HttpStatusCode]::OK
37+
Body = $body
38+
}
3439

3540
}

Modules/CIPPCore/Public/GraphHelper/Write-LogMessage.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ function Write-LogMessage {
6666
if ($tenantId) {
6767
$TableRow.Add('TenantID', [string]$tenantId)
6868
}
69+
if ($script:StandardInfo) {
70+
$TableRow.Standard = [string]$script:StandardInfo.Standard
71+
$TableRow.StandardTemplateId = [string]$script:StandardInfo.StandardTemplateId
72+
if ($script:StandardInfo.IntuneTemplate) {
73+
$TableRow.IntuneTemplateId = [string]$script:StandardInfo.IntuneTemplateId
74+
}
75+
if ($script:StandardInfo.ConditionalAccessTemplate) {
76+
$TableRow.ConditionalAccessTemplateId = [string]$script:StandardInfo.ConditionalAccessTemplateId
77+
}
78+
}
6979

7080
$Table.Entity = $TableRow
7181
Add-CIPPAzDataTableEntity @Table | Out-Null

Modules/CIPPCore/Public/Send-CIPPAlert.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function Send-CIPPAlert {
9595
Write-Information 'Trying to send webhook'
9696

9797
try {
98-
if ($Config.webhook -ne '' -or $AltWebhook -ne '') {
98+
if (![string]::IsNullOrWhiteSpace($Config.webhook) -or ![string]::IsNullOrWhiteSpace($AltWebhook)) {
9999
if ($PSCmdlet.ShouldProcess($Config.webhook, 'Sending webhook')) {
100100
$webhook = if ($AltWebhook) { $AltWebhook } else { $Config.webhook }
101101
switch -wildcard ($webhook) {
@@ -121,8 +121,10 @@ function Send-CIPPAlert {
121121
}
122122
}
123123
}
124+
Write-LogMessage -API 'Webhook Alerts' -message "Sent Webhook alert $title to External webhook" -tenant $TenantFilter -sev info
125+
} else {
126+
Write-LogMessage -API 'Webhook Alerts' -message 'No webhook URL configured' -sev warning
124127
}
125-
Write-LogMessage -API 'Webhook Alerts' -message "Sent Webhook alert $title to External webhook" -tenant $TenantFilter -sev info
126128

127129
} catch {
128130
$ErrorMessage = Get-CippException -Exception $_

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardDisableGuests.ps1

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,17 @@ function Invoke-CIPPStandardDisableGuests {
3333
#>
3434

3535
param($Tenant, $Settings)
36-
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'DisableGuests'
36+
$TestResult = Test-CIPPStandardLicense -StandardName 'DisableGuests' -TenantFilter $Tenant -RequiredCapabilities @('AAD_PREMIUM', 'AAD_PREMIUM_P2')
37+
38+
if ($TestResult -eq $false) {
39+
#writing to each item that the license is not present.
40+
$settings.TemplateList | ForEach-Object {
41+
Set-CIPPStandardsCompareField -FieldName 'standards.DisableGuests' -FieldValue 'This tenant does not have the required license for this standard.' -Tenant $Tenant
42+
}
43+
Write-Host "We're exiting as the correct license is not present for this standard."
44+
return $true
45+
} #we're done.
46+
3747
$checkDays = if ($Settings.days) { $Settings.days } else { 90 } # Default to 90 days if not set. Pre v8.5.0 compatibility
3848
$Days = (Get-Date).AddDays(-$checkDays).ToUniversalTime()
3949
$Lookup = $Days.ToString('o')
@@ -58,7 +68,7 @@ function Invoke-CIPPStandardDisableGuests {
5868
foreach ($guest in $GraphRequest) {
5969
try {
6070
$null = New-GraphPostRequest -type Patch -tenantid $tenant -uri "https://graph.microsoft.com/beta/users/$($guest.id)" -body '{"accountEnabled":"false"}'
61-
Write-LogMessage -API 'Standards' -tenant $tenant -message "Disabling guest $($guest.UserPrincipalName) ($($guest.id))" -sev Info
71+
Write-LogMessage -API 'Standards' -tenant $tenant -message "Disabling guest $($guest.UserPrincipalName) ($($guest.id)). Last sign-in: $($guest.signInActivity.lastSuccessfulSignInDateTime)" -sev Info
6272
} catch {
6373
$ErrorMessage = Get-CippException -Exception $_
6474
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to disable guest $($guest.UserPrincipalName) ($($guest.id)): $($ErrorMessage.NormalizedError)" -sev Error -LogData $ErrorMessage

0 commit comments

Comments
 (0)