Skip to content

Commit 5b2fde3

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into dev
2 parents 6921c77 + 988c08c commit 5b2fde3

11 files changed

Lines changed: 202 additions & 49 deletions

File tree

Cache_SAMSetup/SAMManifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
]
1212
},
1313
"requiredResourceAccess": [
14+
{
15+
"resourceAppId": "aeb86249-8ea3-49e2-900b-54cc8e308f85",
16+
"resourceAccess": [
17+
{ "id": "fc946a4f-bc4d-413b-a090-b2c86113ec4f", "type": "Scope" }
18+
]
19+
},
1420
{
1521
"resourceAppId": "fa3d9a0c-3fb0-42cc-9193-47c7ecd2edbd",
1622
"resourceAccess": [

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Scheduler/Invoke-ListScheduledItems.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ Function Invoke-ListScheduledItems {
1919
$HiddenTasks = $true
2020
}
2121
$Tasks = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq 'ScheduledTask'" | Where-Object { $_.Hidden -ne $HiddenTasks }
22+
if ($Request.Query.Type) {
23+
$tasks.Command
24+
$Tasks = $Tasks | Where-Object { $_.command -eq $Request.Query.Type }
25+
}
26+
2227
$AllowedTenants = Test-CIPPAccess -Request $Request -TenantList
2328
if ($AllowedTenants -notcontains 'AllTenants') {
2429
$Tasks = $Tasks | Where-Object -Property TenantId -In $AllowedTenants
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using namespace System.Net
2+
3+
Function Invoke-ListGroupSenderAuthentication {
4+
[CmdletBinding()]
5+
param($Request, $TriggerMetadata)
6+
7+
$APIName = $TriggerMetadata.FunctionName
8+
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
9+
# Write to the Azure Functions log stream.
10+
Write-Host 'PowerShell HTTP trigger function processed a request.'
11+
12+
# Interact with query parameters or the body of the request.
13+
14+
$TenantFilter = $Request.Query.TenantFilter
15+
$groupid = $Request.query.groupid
16+
$GroupType = $Request.query.Type
17+
18+
$params = @{
19+
Identity = $groupid
20+
}
21+
22+
23+
try {
24+
switch ($GroupType) {
25+
'Distribution List' {
26+
Write-Host 'Checking DL'
27+
$State = (New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-DistributionGroup' -cmdParams $params -UseSystemMailbox $true).RequireSenderAuthenticationEnabled
28+
}
29+
'Microsoft 365' {
30+
Write-Host 'Checking M365 Group'
31+
$State = (New-ExoRequest -tenantid $TenantFilter -cmdlet 'get-unifiedgroup' -cmdParams $params -UseSystemMailbox $true).RequireSenderAuthenticationEnabled
32+
33+
}
34+
default { $state = $true }
35+
}
36+
37+
} catch {
38+
$state = $true
39+
}
40+
41+
# We flip the value because the API is asking if the group is allowed to receive external mail
42+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
43+
StatusCode = [HttpStatusCode]::OK
44+
Body = @{ allowedToReceiveExternal = !$state }
45+
})
46+
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-ExecJITAdmin.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ Function Invoke-ExecJITAdmin {
156156

157157
$DisableTaskBody = @{
158158
TenantFilter = $Request.Body.TenantFilter
159-
Name = "JIT Admin (disable): $Username"
159+
Name = "JIT Admin ($($Request.Body.ExpireAction)): $Username"
160160
Command = @{
161161
value = 'Set-CIPPUserJITAdmin'
162162
label = 'Set-CIPPUserJITAdmin'
@@ -177,7 +177,7 @@ Function Invoke-ExecJITAdmin {
177177
ScheduledTime = $Request.Body.EndDate
178178
}
179179
Add-CIPPScheduledTask -Task $DisableTaskBody -hidden $false
180-
$Results.Add("Scheduling JIT Admin disable task for $Username")
180+
$Results.Add("Scheduling JIT Admin $($Request.Body.ExpireAction) task for $Username")
181181
$Body = @{
182182
Results = @($Results)
183183
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Administration/Alerts/Invoke-ListAlertsQueue.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Function Invoke-ListAlertsQueue {
2020
$WebhookRules = Get-CIPPAzDataTableEntity @WebhookTable
2121

2222
$ScheduledTasks = Get-CIPPTable -TableName 'ScheduledTasks'
23-
$ScheduledTasks = Get-CIPPAzDataTableEntity @ScheduledTasks | Where-Object { $_.hidden -eq $true }
23+
$ScheduledTasks = Get-CIPPAzDataTableEntity @ScheduledTasks | Where-Object { $_.hidden -eq $true -and $_.command -like 'Get-CippAlert*' }
2424

2525
$AllowedTenants = Test-CIPPAccess -Request $Request -TenantList
2626
$TenantList = Get-Tenants -IncludeErrors

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Conditional/Invoke-ListConditionalAccessPolicies.ps1

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ Function Invoke-ListConditionalAccessPolicies {
1919
param (
2020
[Parameter()]
2121
$ID,
22-
23-
[Parameter(Mandatory = $true)]
2422
$Locations
2523
)
2624
if ($id -eq 'All') {
@@ -39,8 +37,6 @@ Function Invoke-ListConditionalAccessPolicies {
3937
param (
4038
[Parameter()]
4139
$ID,
42-
43-
[Parameter(Mandatory = $true)]
4440
$RoleDefinitions
4541
)
4642
if ($id -eq 'All') {
@@ -59,8 +55,6 @@ Function Invoke-ListConditionalAccessPolicies {
5955
param (
6056
[Parameter()]
6157
$ID,
62-
63-
[Parameter(Mandatory = $true)]
6458
$Users
6559
)
6660
if ($id -eq 'All') {
@@ -78,8 +72,6 @@ Function Invoke-ListConditionalAccessPolicies {
7872
param (
7973
[Parameter()]
8074
$ID,
81-
82-
[Parameter(Mandatory = $true)]
8375
$Groups
8476
)
8577
if ($id -eq 'All') {
@@ -98,8 +90,6 @@ Function Invoke-ListConditionalAccessPolicies {
9890
param (
9991
[Parameter()]
10092
$ID,
101-
102-
[Parameter(Mandatory = $true)]
10393
$Applications
10494
)
10595
if ($id -eq 'All') {

Modules/CIPPCore/Public/New-CIPPBackup.ps1

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ function New-CIPPBackup {
44
$backupType,
55
$StorageOutput = 'default',
66
$TenantFilter,
7+
$ScheduledBackupValues,
78
$APIName = 'CIPP Backup',
89
$ExecutingUser
910
)
@@ -50,36 +51,28 @@ function New-CIPPBackup {
5051
}
5152

5253
#If Backup type is ConditionalAccess, create Conditional Access backup.
53-
'ConditionalAccess' {
54-
$ConditionalAccessPolicyOutput = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/identity/conditionalAccess/policies' -tenantid $tenantfilter
55-
$AllNamedLocations = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/identity/conditionalAccess/namedLocations' -tenantid $tenantfilter
56-
switch ($StorageOutput) {
57-
'default' {
58-
[PSCustomObject]@{
59-
ConditionalAccessPolicies = $ConditionalAccessPolicyOutput
60-
NamedLocations = $AllNamedLocations
61-
}
62-
}
63-
'table' {
64-
#Store output in tablestorage for Recovery
65-
$RowKey = $TenantFilter + '_' + (Get-Date).ToString('yyyy-MM-dd-HHmm')
66-
$entity = [PSCustomObject]@{
67-
PartitionKey = 'ConditionalAccessBackup'
68-
RowKey = $RowKey
69-
TenantFilter = $TenantFilter
70-
Policies = [string]($ConditionalAccessPolicyOutput | ConvertTo-Json -Compress -Depth 10)
71-
NamedLocations = [string]($AllNamedLocations | ConvertTo-Json -Compress -Depth 10)
72-
}
73-
$Table = Get-CippTable -tablename 'ConditionalAccessBackup'
74-
try {
75-
$Result = Add-CIPPAzDataTableEntity @Table -entity $entity -Force
76-
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Created backup for Conditional Access Policies' -Sev 'Debug'
77-
$Result
78-
} catch {
79-
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to create backup for Conditional Access Policies: $($_.Exception.Message)" -Sev 'Error'
80-
[pscustomobject]@{'Results' = "Backup Creation failed: $($_.Exception.Message)" }
81-
}
82-
}
54+
'Scheduled' {
55+
#Do a sub switch here based on the ScheduledBackupValues?
56+
#Store output in tablestorage for Recovery
57+
$RowKey = $TenantFilter + '_' + (Get-Date).ToString('yyyy-MM-dd-HHmm')
58+
$entity = @{
59+
PartitionKey = 'ScheduledBackup'
60+
RowKey = $RowKey
61+
TenantFilter = $TenantFilter
62+
}
63+
Write-Host "ScheduledBackupValues: $($ScheduledBackupValues | ConvertTo-Json -Compress -Depth 100)"
64+
Write-Host "Scheduled backup value psproperties: $($ScheduledBackupValues.psobject.Properties.Name)"
65+
foreach ($ScheduledBackup in $ScheduledBackupValues.psobject.Properties.Name) {
66+
$entity[$ScheduledBackup] = New-CIPPBackupTask -Task $ScheduledBackup -TenantFilter $TenantFilter
67+
}
68+
$Table = Get-CippTable -tablename 'ScheduledBackup'
69+
try {
70+
$Result = Add-CIPPAzDataTableEntity @Table -entity $entity -Force
71+
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Created backup for Conditional Access Policies' -Sev 'Debug'
72+
$Result
73+
} catch {
74+
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to create backup for Conditional Access Policies: $($_.Exception.Message)" -Sev 'Error'
75+
[pscustomobject]@{'Results' = "Backup Creation failed: $($_.Exception.Message)" }
8376
}
8477
}
8578

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
function New-CIPPBackupTask {
2+
[CmdletBinding()]
3+
param (
4+
$Task,
5+
$TenantFilter
6+
)
7+
8+
$BackupData = switch ($Task) {
9+
'users' {
10+
$BackupData = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/users?$top=999' -tenantid $TenantFilter
11+
}
12+
'groups' {
13+
$BackupData = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/groups?$top=999' -tenantid $TenantFilter
14+
}
15+
'ca' {
16+
$BackupData = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/conditionalAccess/policies?$top=999' -tenantid $TenantFilter
17+
}
18+
'namedlocations' {
19+
$BackupData = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/conditionalAccess/namedLocations?$top=999' -tenantid $TenantFilter
20+
}
21+
'authstrengths' {
22+
$BackupData = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/conditionalAccess/authenticationStrength/policies' -tenantid $TenantFilter
23+
}
24+
'intuneconfig' {
25+
#alert
26+
}
27+
'intunecompliance' {}
28+
29+
'intuneprotection' {}
30+
31+
'CippWebhookAlerts' {
32+
$WebhookTable = Get-CIPPTable -TableName 'WebhookRules'
33+
$BackupData = Get-CIPPAzDataTableEntity @WebhookTable | Where-Object { $TenantFilter -in ($_.Tenants | ConvertFrom-Json).fullvalue.defaultDomainName }
34+
}
35+
'CippScriptedAlerts' {
36+
$ScheduledTasks = Get-CIPPTable -TableName 'ScheduledTasks'
37+
$BackupData = Get-CIPPAzDataTableEntity @ScheduledTasks | Where-Object { $_.hidden -eq $true -and $_.command -like 'Get-CippAlert*' -and $TenantFilter -in $_.Tenant }
38+
}
39+
'CippStandards' {
40+
$Table = Get-CippTable -tablename 'standards'
41+
$Filter = "PartitionKey eq 'standards' and RowKey eq '$($TenantFilter)'"
42+
$BackupData = (Get-CIPPAzDataTableEntity @Table -Filter $Filter)
43+
}
44+
45+
}
46+
return $BackupData
47+
}
48+

Modules/CIPPCore/Public/SAMManifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
]
1212
},
1313
"requiredResourceAccess": [
14+
{
15+
"resourceAppId": "aeb86249-8ea3-49e2-900b-54cc8e308f85",
16+
"resourceAccess": [
17+
{ "id": "fc946a4f-bc4d-413b-a090-b2c86113ec4f", "type": "Scope" }
18+
]
19+
},
1420
{
1521
"resourceAppId": "fa3d9a0c-3fb0-42cc-9193-47c7ecd2edbd",
1622
"resourceAccess": [

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

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,87 @@ function Invoke-CIPPStandardDisableSelfServiceLicenses {
99
.TAG
1010
"mediumimpact"
1111
.HELPTEXT
12-
This standard currently does not function and can be safely disabled
12+
This standard disables all self service licenses and enables all exclusions
1313
.ADDEDCOMPONENT
1414
.LABEL
1515
Disable Self Service Licensing
1616
.IMPACT
1717
Medium Impact
1818
.POWERSHELLEQUIVALENT
19-
Set-MsolCompanySettings -AllowAdHocSubscriptions $false
19+
Update-MSCommerceProductPolicy -PolicyId AllowSelfServicePurchase -ProductId {productId} -Value "Disabled"
2020
.RECOMMENDEDBY
2121
.DOCSDESCRIPTION
22-
This standard currently does not function and can be safely disabled
22+
This standard disables all self service licenses and enables all exclusions
2323
.UPDATECOMMENTBLOCK
2424
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
2525
#>
2626

27+
param($Tenant, $Settings)
2728

29+
#Write-LogMessage -API 'Standards' -tenant $tenant -message 'Self Service Licenses cannot be disabled' -sev Error
30+
try {
31+
$selfServiceItems = (New-GraphGETRequest -scope "aeb86249-8ea3-49e2-900b-54cc8e308f85/.default" -uri "https://licensing.m365.microsoft.com/v1.0/policies/AllowSelfServicePurchase/products" -tenantid $Tenant).items
32+
#$selfServiceItems = (Invoke-RestMethod -Method GET -Uri "https://licensing.m365.microsoft.com/v1.0/policies/AllowSelfServicePurchase/products" -Headers $header).items
33+
} catch {
34+
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to retrieve self service products: $($_.Exception.Message)" -sev Error
35+
throw "Failed to retrieve self service products: $($_.Exception.Message)"
36+
}
2837

38+
if ($settings.remediate) {
39+
if ($settings.exclusions -like "*;*") {
40+
$exclusions = $settings.Exclusions -split(';')
41+
} else {
42+
$exclusions = $settings.Exclusions -split(',')
43+
}
2944

30-
param($Tenant, $Settings)
45+
$selfServiceItems | ForEach-Object {
46+
$body = $null
47+
48+
if ($_.policyValue -eq "Enabled" -AND ($_.productId -in $exclusions)) {
49+
# Self service is enabled on product and productId is in exclusions, skip
50+
}
51+
if ($_.policyValue -eq "Disabled" -AND ($_.productId -in $exclusions)) {
52+
# Self service is disabled on product and productId is in exclusions, enable
53+
$body = '{ "policyValue": "Enabled" }'
54+
}
55+
if ($_.policyValue -eq "Enabled" -AND ($_.productId -notin $exclusions)) {
56+
# Self service is enabled on product and productId is NOT in exclusions, disable
57+
$body = '{ "policyValue": "Disabled" }'
58+
}
59+
if ($_.policyValue -eq "Disabled" -AND ($_.productId -notin $exclusions)) {
60+
# Self service is disabled on product and productId is NOT in exclusions, skip
61+
}
62+
63+
try {
64+
if ($body) {
65+
$product = $_
66+
New-GraphPOSTRequest -scope "aeb86249-8ea3-49e2-900b-54cc8e308f85/.default" -uri "https://licensing.m365.microsoft.com/v1.0/policies/AllowSelfServicePurchase/products/$($product.productId)" -tenantid $Tenant -body $body -type PUT
67+
}
68+
} catch {
69+
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to set product status for $($product.productId) with body $($body) for reason: $($_.Exception.Message)" -sev Error
70+
#Write-Error "Failed to disable product $($product.productName):$($_.Exception.Message)"
71+
}
72+
}
73+
74+
if (!$exclusions) {
75+
Write-LogMessage -API 'Standards' -tenant $Tenant -message 'No exclusions set for self-service licenses, disabled all not excluded licenses for self-service.' -sev Info
76+
} else {
77+
Write-LogMessage -API 'Standards' -tenant $Tenant -message 'Exclusions present for self-service licenses, disabled all not excluded licenses for self-service.' -sev Info
78+
}
79+
}
3180

32-
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Self Service Licenses cannot be disabled' -sev Error
81+
if ($Settings.alert) {
82+
$selfServiceItemsToAlert = $selfServiceItems | Where-Object { $_.policyValue -eq "Enabled"}
83+
if (!$selfServiceItemsToAlert) {
84+
Write-LogMessage -API 'Standards' -tenant $tenant -message 'All self-service licenses are disabled' -sev Info
85+
} else {
86+
Write-LogMessage -API 'Standards' -tenant $tenant -message 'One or more self-service licenses are enabled' -sev Alert
87+
}
88+
}
3389

90+
if ($Settings.report -eq $true) {
91+
#Add-CIPPBPAField -FieldName '????' -FieldValue "????" -StoreAs bool -Tenant $tenant
92+
}
3493
}
3594

3695

0 commit comments

Comments
 (0)