Skip to content

Commit cd7fe49

Browse files
Merge pull request #1560 from KelvinTegelaar/dev
Dev to hotfix
2 parents b58324a + ada5e37 commit cd7fe49

File tree

103 files changed

+628
-118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+628
-118
lines changed

Modules/CIPPCore/Public/Alerts/Get-CIPPAlertOnedriveQuota.ps1

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,20 @@ function Get-CIPPAlertOneDriveQuota {
44
Entrypoint
55
#>
66
[CmdletBinding()]
7-
Param (
7+
param (
88
[Parameter(Mandatory)]
99
$TenantFilter,
1010
[Alias('input')]
11-
[ValidateRange(0,100)]
11+
[ValidateRange(0, 100)]
1212
[int]$InputValue = 90
1313
)
1414

1515
try {
1616
$Usage = New-GraphGetRequest -tenantid $TenantFilter -uri "https://graph.microsoft.com/beta/reports/getOneDriveUsageAccountDetail(period='D7')?`$format=application/json&`$top=999" -AsApp $true
1717
if (!$Usage) {
18-
Write-AlertMessage -tenant $($TenantFilter) -message "OneDrive quota Alert: Unable to get OneDrive usage: Error occurred: No data returned from API."
1918
return
2019
}
21-
}
22-
catch {
20+
} catch {
2321
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
2422
Write-AlertMessage -tenant $($TenantFilter) -message "OneDrive quota Alert: Unable to get OneDrive usage: Error occurred: $ErrorMessage"
2523
return
@@ -29,7 +27,7 @@ function Get-CIPPAlertOneDriveQuota {
2927
$OverQuota = $Usage | ForEach-Object {
3028
if ($_.StorageUsedInBytes -eq 0 -or $_.storageAllocatedInBytes -eq 0) { return }
3129
try {
32-
$UsagePercent = [math]::Round(($_.storageUsedInBytes / $_.storageAllocatedInBytes) * 100)
30+
$UsagePercent = [math]::Round(($_.storageUsedInBytes / $_.storageAllocatedInBytes) * 100)
3331
} catch { $UsagePercent = 100 }
3432

3533
if ($UsagePercent -gt $InputValue) {

Modules/CIPPCore/Public/Functions/Test-CIPPStandardLicense.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ function Test-CIPPStandardLicense {
4444
Write-LogMessage -API 'Standards' -tenant $TenantFilter -message "Tenant does not have the required capability to run standard $StandardName`: The tenant needs one of the following service plans: $($RequiredCapabilities -join ',')" -sev Error
4545
Set-CIPPStandardsCompareField -FieldName "standards.$StandardName" -FieldValue "License Missing: This tenant is not licensed for the following capabilities: $($RequiredCapabilities -join ',')" -Tenant $TenantFilter
4646
Write-Host "Tenant does not have the required capability to run standard $StandardName - $($RequiredCapabilities -join ','). Exiting"
47-
exit 0
47+
return $false
4848
}
4949
Write-Host "Tenant has the required capabilities for standard $StandardName"
50+
return $true
5051
} catch {
5152
Write-LogMessage -API 'Standards' -tenant $TenantFilter -message "Error checking license capabilities for standard $StandardName`: $($_.Exception.Message)" -sev Error
5253
Set-CIPPStandardsCompareField -FieldName "standards.$StandardName" -FieldValue "License Missing: Error checking license capabilities - $($_.Exception.Message)" -Tenant $TenantFilter
53-
exit 0
54+
return $false
5455
}
5556
}

Modules/CIPPCore/Public/Get-CIPPTenantCapabilities.ps1

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,21 @@ function Get-CIPPTenantCapabilities {
66
$APIName = 'Get Tenant Capabilities',
77
$Headers
88
)
9-
10-
$Org = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscribedSkus' -tenantid $TenantFilter
9+
$ConfigTable = Get-CIPPTable -TableName 'CacheCapabilities'
10+
$datetime = (Get-Date).AddDays(-1).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
11+
$ConfigEntries = Get-CIPPAzDataTableEntity @ConfigTable -Filter "RowKey eq '$TenantFilter' and Timestamp ge datetime'$datetime'"
12+
if ($ConfigEntries) {
13+
$Org = $ConfigEntries.JSON | ConvertFrom-Json
14+
} else {
15+
$Org = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscribedSkus' -tenantid $TenantFilter
16+
# Save the capabilities to the cache table
17+
$Entity = @{
18+
PartitionKey = 'Capabilities'
19+
RowKey = $TenantFilter
20+
JSON = "$($Org | ConvertTo-Json -Compress -Depth 10)"
21+
}
22+
Add-CIPPAzDataTableEntity @ConfigTable -Entity $Entity -Force
23+
}
1124
$Plans = $Org.servicePlans | Where-Object { $_.provisioningStatus -eq 'Success' } | Sort-Object -Property serviceplanName -Unique | Select-Object servicePlanName, provisioningStatus
1225
$Results = @{}
1326
foreach ($Plan in $Plans) {

Modules/CIPPCore/Public/New-CIPPTemplateRun.ps1

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ function New-CIPPTemplateRun {
66
)
77
$Table = Get-CippTable -tablename 'templates'
88
$ExistingTemplates = (Get-CIPPAzDataTableEntity @Table) | ForEach-Object {
9-
$data = $_.JSON | ConvertFrom-Json -ErrorAction SilentlyContinue -Depth 100
10-
$data | Add-Member -NotePropertyName 'GUID' -NotePropertyValue $_.RowKey -Force
11-
$data | Add-Member -NotePropertyName 'PartitionKey' -NotePropertyValue $_.PartitionKey -Force
12-
$data | Add-Member -NotePropertyName 'SHA' -NotePropertyValue $_.SHA -Force
13-
$data
9+
try {
10+
$data = $_.JSON | ConvertFrom-Json -ErrorAction SilentlyContinue -Depth 100
11+
$data | Add-Member -NotePropertyName 'GUID' -NotePropertyValue $_.RowKey -Force -ErrorAction Stop
12+
$data | Add-Member -NotePropertyName 'PartitionKey' -NotePropertyValue $_.PartitionKey -Force -ErrorAction Stop
13+
$data | Add-Member -NotePropertyName 'SHA' -NotePropertyValue $_.SHA -Force -ErrorAction Stop
14+
$data
15+
} catch {
16+
return
17+
}
1418
} | Sort-Object -Property displayName
1519

1620
function Get-SanitizedFilename {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ function Invoke-CIPPStandardAddDKIM {
3232

3333
param($Tenant, $Settings)
3434
#$Rerun -Type Standard -Tenant $Tenant -API 'AddDKIM' -Settings $Settings
35-
Test-CIPPStandardLicense -StandardName 'AddDKIM' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
35+
$TestResult = Test-CIPPStandardLicense -StandardName 'AddDKIM' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
36+
37+
if ($TestResult -eq $false) {
38+
Write-Host "We're exiting as the correct license is not present for this standard."
39+
return $true
40+
} #we're done.
3641

3742
$DkimRequest = @(
3843
@{

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ function Invoke-CIPPStandardAntiPhishPolicy {
5050
#>
5151

5252
param($Tenant, $Settings)
53-
Test-CIPPStandardLicense -StandardName 'AntiPhishPolicy' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
53+
$TestResult = Test-CIPPStandardLicense -StandardName 'AntiPhishPolicy' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
54+
55+
if ($TestResult -eq $false) {
56+
Write-Host "We're exiting as the correct license is not present for this standard."
57+
return $true
58+
} #we're done.
5459
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'AntiPhishPolicy'
5560

5661
$ServicePlans = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscribedSkus?$select=servicePlans' -tenantid $Tenant

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ function Invoke-CIPPStandardAntiSpamSafeList {
2929
#>
3030

3131
param($Tenant, $Settings)
32-
Test-CIPPStandardLicense -StandardName 'AntiSpamSafeList' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
32+
$TestResult = Test-CIPPStandardLicense -StandardName 'AntiSpamSafeList' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
33+
34+
if ($TestResult -eq $false) {
35+
Write-Host "We're exiting as the correct license is not present for this standard."
36+
return $true
37+
} #we're done.
3338
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'AntiSpamSafeList'
3439

3540
try {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@ function Invoke-CIPPStandardAtpPolicyForO365 {
3131
#>
3232

3333
param($Tenant, $Settings)
34-
Test-CIPPStandardLicense -StandardName 'AtpPolicyForO365' -TenantFilter $Tenant -RequiredCapabilities @('SHAREPOINTWAC', 'SHAREPOINTSTANDARD', 'SHAREPOINTENTERPRISE', 'ONEDRIVE_BASIC', 'ONEDRIVE_ENTERPRISE')
34+
$TestResult = Test-CIPPStandardLicense -StandardName 'AtpPolicyForO365' -TenantFilter $Tenant -RequiredCapabilities @('SHAREPOINTWAC', 'SHAREPOINTSTANDARD', 'SHAREPOINTENTERPRISE', 'ONEDRIVE_BASIC', 'ONEDRIVE_ENTERPRISE')
3535
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'AtpPolicyForO365'
36+
37+
if ($TestResult -eq $false) {
38+
Write-Host "We're exiting as the correct license is not present for this standard."
39+
return $true
40+
} #we're done.
3641
try {
3742
$CurrentState = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-AtpPolicyForO365' |
3843
Select-Object EnableATPForSPOTeamsODB, EnableSafeDocs, AllowSafeDocsOpen

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ function Invoke-CIPPStandardAuditLog {
3232
#>
3333

3434
param($Tenant, $Settings)
35-
Test-CIPPStandardLicense -StandardName 'AuditLog' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
35+
$TestResult = Test-CIPPStandardLicense -StandardName 'AuditLog' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
36+
37+
if ($TestResult -eq $false) {
38+
Write-Host "We're exiting as the correct license is not present for this standard."
39+
return $true
40+
} #we're done.
3641
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'AuditLog'
3742

3843
Write-Host ($Settings | ConvertTo-Json)

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ function Invoke-CIPPStandardAutoExpandArchive {
2828
#>
2929

3030
param($Tenant, $Settings)
31-
Test-CIPPStandardLicense -StandardName 'AutoExpandArchive' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
31+
$TestResult = Test-CIPPStandardLicense -StandardName 'AutoExpandArchive' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
32+
33+
if ($TestResult -eq $false) {
34+
Write-Host "We're exiting as the correct license is not present for this standard."
35+
return $true
36+
} #we're done.
3237
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'AutoExpandArchive'
3338

3439
$CurrentState = (New-ExoRequest -tenantid $Tenant -cmdlet 'Get-OrganizationConfig').AutoExpandingArchiveEnabled

0 commit comments

Comments
 (0)