Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Modules/CIPPCore/Public/Alerts/Get-CIPPAlertOnedriveQuota.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@ function Get-CIPPAlertOneDriveQuota {
Entrypoint
#>
[CmdletBinding()]
Param (
param (
[Parameter(Mandatory)]
$TenantFilter,
[Alias('input')]
[ValidateRange(0,100)]
[ValidateRange(0, 100)]
[int]$InputValue = 90
)

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

if ($UsagePercent -gt $InputValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ function Test-CIPPStandardLicense {
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
Set-CIPPStandardsCompareField -FieldName "standards.$StandardName" -FieldValue "License Missing: This tenant is not licensed for the following capabilities: $($RequiredCapabilities -join ',')" -Tenant $TenantFilter
Write-Host "Tenant does not have the required capability to run standard $StandardName - $($RequiredCapabilities -join ','). Exiting"
exit 0
return $false
}
Write-Host "Tenant has the required capabilities for standard $StandardName"
return $true
} catch {
Write-LogMessage -API 'Standards' -tenant $TenantFilter -message "Error checking license capabilities for standard $StandardName`: $($_.Exception.Message)" -sev Error
Set-CIPPStandardsCompareField -FieldName "standards.$StandardName" -FieldValue "License Missing: Error checking license capabilities - $($_.Exception.Message)" -Tenant $TenantFilter
exit 0
return $false
}
}
17 changes: 15 additions & 2 deletions Modules/CIPPCore/Public/Get-CIPPTenantCapabilities.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,21 @@ function Get-CIPPTenantCapabilities {
$APIName = 'Get Tenant Capabilities',
$Headers
)

$Org = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscribedSkus' -tenantid $TenantFilter
$ConfigTable = Get-CIPPTable -TableName 'CacheCapabilities'
$datetime = (Get-Date).AddDays(-1).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
$ConfigEntries = Get-CIPPAzDataTableEntity @ConfigTable -Filter "RowKey eq '$TenantFilter' and Timestamp ge datetime'$datetime'"
if ($ConfigEntries) {
$Org = $ConfigEntries.JSON | ConvertFrom-Json
} else {
$Org = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscribedSkus' -tenantid $TenantFilter
# Save the capabilities to the cache table
$Entity = @{
PartitionKey = 'Capabilities'
RowKey = $TenantFilter
JSON = "$($Org | ConvertTo-Json -Compress -Depth 10)"
}
Add-CIPPAzDataTableEntity @ConfigTable -Entity $Entity -Force
}
$Plans = $Org.servicePlans | Where-Object { $_.provisioningStatus -eq 'Success' } | Sort-Object -Property serviceplanName -Unique | Select-Object servicePlanName, provisioningStatus
$Results = @{}
foreach ($Plan in $Plans) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ function Invoke-CIPPStandardAddDKIM {

param($Tenant, $Settings)
#$Rerun -Type Standard -Tenant $Tenant -API 'AddDKIM' -Settings $Settings
Test-CIPPStandardLicense -StandardName 'AddDKIM' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
$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

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.

$DkimRequest = @(
@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ function Invoke-CIPPStandardAntiPhishPolicy {
#>

param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'AntiPhishPolicy' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
$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

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'AntiPhishPolicy'

$ServicePlans = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscribedSkus?$select=servicePlans' -tenantid $Tenant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ function Invoke-CIPPStandardAntiSpamSafeList {
#>

param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'AntiSpamSafeList' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
$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

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'AntiSpamSafeList'

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ function Invoke-CIPPStandardAtpPolicyForO365 {
#>

param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'AtpPolicyForO365' -TenantFilter $Tenant -RequiredCapabilities @('SHAREPOINTWAC', 'SHAREPOINTSTANDARD', 'SHAREPOINTENTERPRISE', 'ONEDRIVE_BASIC', 'ONEDRIVE_ENTERPRISE')
$TestResult = Test-CIPPStandardLicense -StandardName 'AtpPolicyForO365' -TenantFilter $Tenant -RequiredCapabilities @('SHAREPOINTWAC', 'SHAREPOINTSTANDARD', 'SHAREPOINTENTERPRISE', 'ONEDRIVE_BASIC', 'ONEDRIVE_ENTERPRISE')
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'AtpPolicyForO365'

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.
try {
$CurrentState = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-AtpPolicyForO365' |
Select-Object EnableATPForSPOTeamsODB, EnableSafeDocs, AllowSafeDocsOpen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ function Invoke-CIPPStandardAuditLog {
#>

param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'AuditLog' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
$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

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'AuditLog'

Write-Host ($Settings | ConvertTo-Json)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ function Invoke-CIPPStandardAutoExpandArchive {
#>

param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'AutoExpandArchive' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
$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

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'AutoExpandArchive'

$CurrentState = (New-ExoRequest -tenantid $Tenant -cmdlet 'Get-OrganizationConfig').AutoExpandingArchiveEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ function Invoke-CIPPStandardAutopilotProfile {
https://docs.cipp.app/user-documentation/tenant/standards/list-standards
#>
param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'AutopilotProfile' -TenantFilter $Tenant -RequiredCapabilities @('INTUNE_A', 'MDM_Services', 'EMS', 'SCCM', 'MICROSOFTINTUNEPLAN1')
$TestResult = Test-CIPPStandardLicense -StandardName 'AutopilotProfile' -TenantFilter $Tenant -RequiredCapabilities @('INTUNE_A', 'MDM_Services', 'EMS', 'SCCM', 'MICROSOFTINTUNEPLAN1')

# Get the current configuration

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.
try {
# Replace variables in displayname to prevent duplicates
$DisplayName = Get-CIPPTextReplacement -Text $Settings.DisplayName -TenantFilter $Tenant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ function Invoke-CIPPStandardAutopilotStatusPage {
https://docs.cipp.app/user-documentation/tenant/standards/list-standards
#>
param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'AutopilotStatusPage' -TenantFilter $Tenant -RequiredCapabilities @('INTUNE_A', 'MDM_Services', 'EMS', 'SCCM', 'MICROSOFTINTUNEPLAN1')
$TestResult = Test-CIPPStandardLicense -StandardName 'AutopilotStatusPage' -TenantFilter $Tenant -RequiredCapabilities @('INTUNE_A', 'MDM_Services', 'EMS', 'SCCM', 'MICROSOFTINTUNEPLAN1')

# Get current Autopilot enrollment status page configuration

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.
try {
$CurrentConfig = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/deviceManagement/deviceEnrollmentConfigurations?`$expand=assignments&orderBy=priority&`$filter=deviceEnrollmentConfigurationType eq 'windows10EnrollmentCompletionPageConfiguration' and priority eq 0" -tenantid $Tenant |
Select-Object -Property id, displayName, priority, showInstallationProgress, blockDeviceSetupRetryByUser, allowDeviceResetOnInstallFailure, allowLogCollectionOnInstallFailure, customErrorMessage, installProgressTimeoutInMinutes, allowDeviceUseOnInstallFailure, trackInstallProgressForAutopilotOnly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ function Invoke-CIPPStandardBookings {
#>

param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'Bookings' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
$TestResult = Test-CIPPStandardLicense -StandardName 'Bookings' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'Bookings'

# Get state value using null-coalescing operator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ function Invoke-CIPPStandardCloudMessageRecall {
#>

param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'CloudMessageRecall' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
$TestResult = Test-CIPPStandardLicense -StandardName 'CloudMessageRecall' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'CloudMessageRecall'

# Get state value using null-coalescing operator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ function Invoke-CIPPStandardConditionalAccessTemplate {
#>
param($Tenant, $Settings)
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'ConditionalAccess'
Test-CIPPStandardLicense -StandardName 'ConditionalAccessTemplate' -TenantFilter $Tenant -RequiredCapabilities @('AAD_PREMIUM', 'AAD_PREMIUM_P2')
$TestResult = Test-CIPPStandardLicense -StandardName 'ConditionalAccessTemplate' -TenantFilter $Tenant -RequiredCapabilities @('AAD_PREMIUM', 'AAD_PREMIUM_P2')

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.

if ($Settings.remediate -eq $true) {
$AllCAPolicies = New-GraphGetRequest -Uri 'https://graph.microsoft.com/beta/identity/conditionalAccess/policies?$top=999' -tenantid $Tenant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ function Invoke-CIPPStandardDefaultPlatformRestrictions {
#>

param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'DefaultPlatformRestrictions' -TenantFilter $Tenant -RequiredCapabilities @('INTUNE_A', 'MDM_Services', 'EMS', 'SCCM', 'MICROSOFTINTUNEPLAN1')
$TestResult = Test-CIPPStandardLicense -StandardName 'DefaultPlatformRestrictions' -TenantFilter $Tenant -RequiredCapabilities @('INTUNE_A', 'MDM_Services', 'EMS', 'SCCM', 'MICROSOFTINTUNEPLAN1')

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.

try {
$CurrentState = New-GraphGetRequest -Uri "https://graph.microsoft.com/beta/deviceManagement/deviceEnrollmentConfigurations?`$expand=assignments&orderBy=priority&`$filter=deviceEnrollmentConfigurationType eq 'SinglePlatformRestriction'" -tenantID $Tenant -AsApp $true |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ function Invoke-CIPPStandardDefaultSharingLink {
#>

param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'DefaultSharingLink' -TenantFilter $Tenant -RequiredCapabilities @('SHAREPOINTWAC', 'SHAREPOINTSTANDARD', 'SHAREPOINTENTERPRISE', 'ONEDRIVE_BASIC', 'ONEDRIVE_ENTERPRISE')
$TestResult = Test-CIPPStandardLicense -StandardName 'DefaultSharingLink' -TenantFilter $Tenant -RequiredCapabilities @('SHAREPOINTWAC', 'SHAREPOINTSTANDARD', 'SHAREPOINTENTERPRISE', 'ONEDRIVE_BASIC', 'ONEDRIVE_ENTERPRISE')

# Determine the desired sharing link type (default to Internal if not specified)

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.
$DesiredSharingLinkType = $Settings.SharingLinkType.value ?? 'Internal'

# Map the string values to numeric values for SharePoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ function Invoke-CIPPStandardDelegateSentItems {
#>

param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'DelegateSentItems' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
$TestResult = Test-CIPPStandardLicense -StandardName 'DelegateSentItems' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.
#$Rerun -Type Standard -Tenant $Tenant -API 'DelegateSentItems' -Settings $Settings


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ function Invoke-CIPPStandardDeletedUserRentention {
#>

param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'DeletedUserRentention' -TenantFilter $Tenant -RequiredCapabilities @('SHAREPOINTWAC', 'SHAREPOINTSTANDARD', 'SHAREPOINTENTERPRISE', 'ONEDRIVE_BASIC', 'ONEDRIVE_ENTERPRISE')
$TestResult = Test-CIPPStandardLicense -StandardName 'DeletedUserRentention' -TenantFilter $Tenant -RequiredCapabilities @('SHAREPOINTWAC', 'SHAREPOINTSTANDARD', 'SHAREPOINTENTERPRISE', 'ONEDRIVE_BASIC', 'ONEDRIVE_ENTERPRISE')
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'DeletedUserRetention'

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.

$CurrentInfo = New-GraphGetRequest -Uri 'https://graph.microsoft.com/beta/admin/sharepoint/settings' -tenantid $Tenant -AsApp $true
$Days = $Settings.Days.value ?? $Settings.Days

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ function Invoke-CIPPStandardDeployContactTemplates {
#>

param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'DeployContactTemplates' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
$TestResult = Test-CIPPStandardLicense -StandardName 'DeployContactTemplates' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.

$APIName = 'Standards'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ function Invoke-CIPPStandardDeployMailContact {
#>

param($Tenant, $Settings)
Test-CIPPStandardLicense -StandardName 'DeployMailContact' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access
$TestResult = Test-CIPPStandardLicense -StandardName 'DeployMailContact' -TenantFilter $Tenant -RequiredCapabilities @('EXCHANGE_S_STANDARD', 'EXCHANGE_S_ENTERPRISE', 'EXCHANGE_LITE') #No Foundation because that does not allow powershell access

if ($TestResult -eq $false) {
Write-Host "We're exiting as the correct license is not present for this standard."
return $true
} #we're done.

# Input validation
if ([string]::IsNullOrWhiteSpace($Settings.DisplayName)) {
Expand Down
Loading