Skip to content

Commit

Permalink
Merge branch 'KelvinTegelaar:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
CentralizedServices authored Jun 19, 2024
2 parents 778a8b9 + 285e24c commit f1d35a6
Show file tree
Hide file tree
Showing 379 changed files with 6,134 additions and 2,202 deletions.
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
insert_final_newline = true

[*.{ps1, psd1, psm1}]
indent_size = 4
end_of_line = crlf
trim_trailing_whitespace = true

[*.json]
indent_size = 2
end_of_line = crlf
trim_trailing_whitespace = true

[*.{md, txt}]
end_of_line = crlf
max_line_length = off
trim_trailing_whitespace = false
1 change: 0 additions & 1 deletion BestPracticeAnalyser_OrchestrationStarter/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ $InputObject = [PSCustomObject]@{
Batch = @($BPAReports)
OrchestratorName = 'BPAOrchestrator'
SkipLog = $true
DurableMode = 'Sequence'
}
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Compress -Depth 5)

Expand Down
1 change: 0 additions & 1 deletion BestPracticeAnalyser_OrchestrationStarterTimer/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ $InputObject = [PSCustomObject]@{
Batch = @($BPAReports)
OrchestratorName = 'BPAOrchestrator'
SkipLog = $true
DurableMode = 'Sequence'
}
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Compress -Depth 5)
4 changes: 3 additions & 1 deletion Cache_SAMSetup/SAMManifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@
{ "id": "885f682f-a990-4bad-a642-36736a74b0c7", "type": "Scope" },
{ "id": "913b9306-0ce1-42b8-9137-6a7df690a760", "type": "Role" },
{ "id": "cb8f45a0-5c2e-4ea1-b803-84b870a7d7ec", "type": "Scope" },
{ "id": "4c06a06a-098a-4063-868e-5dfee3827264", "type": "Scope" }
{ "id": "4c06a06a-098a-4063-868e-5dfee3827264", "type": "Scope" },
{ "id": "1bfefb4e-e0b5-418b-a88f-73c46d2cc8e9", "type": "Role" },
{ "id": "e67e6727-c080-415e-b521-e3f35d5248e9", "type": "Scope" }
]
},
{
Expand Down
1 change: 0 additions & 1 deletion DomainAnalyser_OrchestrationStarter/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ $InputObject = [PSCustomObject]@{
}
OrchestratorName = 'DomainAnalyser_Tenants'
SkipLog = $true
DurableMode = 'Sequence'
}
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Compress -Depth 5)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ function Get-CIPPAlertAdminPassword {
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function Get-CIPPAlertApnCertExpiry {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)

Expand Down
30 changes: 14 additions & 16 deletions Modules/CIPPCore/Public/Alerts/Get-CIPPAlertAppSecretExpiry.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,28 @@ function Get-CIPPAlertAppSecretExpiry {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)

try {
Write-Host "Checking app expire for $($TenantFilter)"
$appList = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/applications?`$select=appId,displayName,passwordCredentials" -tenantid $TenantFilter
$AlertData = foreach ($App in $applist) {
Write-Host "checking $($App.displayName)"
if ($App.passwordCredentials) {
foreach ($Credential in $App.passwordCredentials) {
if ($Credential.endDateTime -lt (Get-Date).AddDays(30) -and $Credential.endDateTime -gt (Get-Date).AddDays(-7)) {
Write-Host ("Application '{0}' has secrets expiring on {1}" -f $App.displayName, $Credential.endDateTime)
@{ DisplayName = $App.displayName; Expires = $Credential.endDateTime }
}
} catch {
return
}

$AlertData = foreach ($App in $applist) {
Write-Host "checking $($App.displayName)"
if ($App.passwordCredentials) {
foreach ($Credential in $App.passwordCredentials) {
if ($Credential.endDateTime -lt (Get-Date).AddDays(30) -and $Credential.endDateTime -gt (Get-Date).AddDays(-7)) {
Write-Host ("Application '{0}' has secrets expiring on {1}" -f $App.displayName, $Credential.endDateTime)
@{ DisplayName = $App.displayName; Expires = $Credential.endDateTime }
}
}
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData

} else {
Write-Host "Skipping app expire for $($TenantFilter)"
}
} catch {
#Write-AlertMessage -tenant $($TenantFilter) -message "Failed to check App registration expiry for $($TenantFilter): $(Get-NormalizedError -message $_.Exception.message)"
}
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ function Get-CIPPAlertDefenderMalware {
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function Get-CIPPAlertDefenderStatus {
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function Get-CIPPAlertDepTokenExpiry {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)

Expand All @@ -22,7 +23,7 @@ function Get-CIPPAlertDepTokenExpiry {

} catch {}


} catch {
Write-AlertMessage -tenant $($TenantFilter) -message "Failed to check Apple Device Enrollment Program token expiry for $($TenantFilter): $(Get-NormalizedError -message $_.Exception.message)"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function Get-CIPPAlertExpiringLicenses {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)
try {
Expand Down
3 changes: 2 additions & 1 deletion Modules/CIPPCore/Public/Alerts/Get-CIPPAlertMFAAdmins.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function Get-CIPPAlertMFAAdmins {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function Get-CIPPAlertMFAAlertUsers {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ function Get-CIPPAlertNewAppApproval {
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)
try {
Expand Down
3 changes: 2 additions & 1 deletion Modules/CIPPCore/Public/Alerts/Get-CIPPAlertNewRole.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function Get-CIPPAlertNewRole {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)
$Deltatable = Get-CIPPTable -Table DeltaCompare
Expand Down
3 changes: 2 additions & 1 deletion Modules/CIPPCore/Public/Alerts/Get-CIPPAlertNoCAConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function Get-CIPPAlertNoCAConfig {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function Get-CIPPAlertOverusedLicenses {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)

Expand Down
27 changes: 15 additions & 12 deletions Modules/CIPPCore/Public/Alerts/Get-CIPPAlertQuotaUsed.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@ function Get-CIPPAlertQuotaUsed {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)


try {
$AlertData = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/reports/getMailboxUsageDetail(period='D7')?`$format=application/json" -tenantid $TenantFilter | ForEach-Object {
if ($_.StorageUsedInBytes -eq 0) { return }
$PercentLeft = [math]::round($_.StorageUsedInBytes / $_.prohibitSendReceiveQuotaInBytes * 100)
if ($Input) { $Value = $input } else { $Value = 90 }
if ($PercentLeft -gt $Value) {
"$($_.UserPrincipalName): Mailbox is more than $($value)% full. Mailbox is $PercentLeft% full"
}

}
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
$AlertData = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/reports/getMailboxUsageDetail(period='D7')?`$format=application/json" -tenantid $TenantFilter
} catch {
return
}
$AlertData | ForEach-Object {
if ($_.StorageUsedInBytes -eq 0) { return }
$PercentLeft = [math]::round(($_.storageUsedInBytes / $_.prohibitSendReceiveQuotaInBytes) * 100)
if ($InputValue) { $Value = [int]$InputValue } else { $Value = 90 }
if ($PercentLeft -gt $Value) {
"$($_.userPrincipalName): Mailbox is more than $($value)% full. Mailbox is $PercentLeft% full"
}

}
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function Get-CIPPAlertSecDefaultsUpsell {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)

Expand Down
22 changes: 11 additions & 11 deletions Modules/CIPPCore/Public/Alerts/Get-CIPPAlertSharepointQuota.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ function Get-CIPPAlertSharepointQuota {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)
Try {
$tenantName = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/domains' -tenantid $TenantFilter | Where-Object { $_.isInitial -eq $true }).id.Split('.')[0]
$sharepointToken = (Get-GraphToken -scope "https://$($tenantName)-admin.sharepoint.com/.default" -tenantid $TenantFilter)
$sharepointToken.Add('accept', 'application/json')
$sharepointQuota = (Invoke-RestMethod -Method 'GET' -Headers $sharepointToken -Uri "https://$($tenantName)-admin.sharepoint.com/_api/StorageQuotas()?api-version=1.3.2" -ErrorAction Stop).value
if ($sharepointQuota) {
if ($input -Is [Boolean]) { $Value = 90 } else { $Value = $input }
$UsedStoragePercentage = [int](($sharepointQuota.GeoUsedStorageMB / $sharepointQuota.TenantStorageMB) * 100)
if ($UsedStoragePercentage -gt $Value) {
$AlertData = "SharePoint Storage is at $($UsedStoragePercentage)%. Your alert threshold is $($Value)%"
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
}
}
} catch {
return
}
if ($sharepointQuota) {
if ($InputValue -Is [Boolean]) { $Value = 90 } else { $Value = $InputValue }
$UsedStoragePercentage = [int](($sharepointQuota.GeoUsedStorageMB / $sharepointQuota.TenantStorageMB) * 100)
if ($UsedStoragePercentage -gt $Value) {
$AlertData = "SharePoint Storage is at $($UsedStoragePercentage)%. Your alert threshold is $($Value)%"
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function Get-CIPPAlertUnusedLicenses {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function Get-CIPPAlertVppTokenExpiry {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
$input,
[Alias('input')]
$InputValue,
$TenantFilter
)
try {
Expand All @@ -23,7 +24,7 @@ function Get-CIPPAlertVppTokenExpiry {
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData

} catch {}

} catch {
# Error handling
}
Expand Down
27 changes: 27 additions & 0 deletions Modules/CIPPCore/Public/Assert-CippVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function Assert-CippVersion {
<#
.SYNOPSIS
Compare the local version of CIPP with the latest version.
.DESCRIPTION
Retrieves the local version of CIPP and compares it with the latest version in GitHub.
.PARAMETER CIPPVersion
Local version of CIPP frontend
#>
Param($CIPPVersion)
$APIVersion = (Get-Content 'version_latest.txt' -Raw).trim()

$RemoteAPIVersion = (Invoke-RestMethod -Uri 'https://raw.githubusercontent.com/KelvinTegelaar/CIPP-API/master/version_latest.txt').trim()
$RemoteCIPPVersion = (Invoke-RestMethod -Uri 'https://raw.githubusercontent.com/KelvinTegelaar/CIPP/master/public/version_latest.txt').trim()

[PSCustomObject]@{
LocalCIPPVersion = $CIPPVersion
RemoteCIPPVersion = $RemoteCIPPVersion
LocalCIPPAPIVersion = $APIVersion
RemoteCIPPAPIVersion = $RemoteAPIVersion
OutOfDateCIPP = ([version]$RemoteCIPPVersion -gt [version]$CIPPVersion)
OutOfDateCIPPAPI = ([version]$RemoteAPIVersion -gt [version]$APIVersion)
}
}
Loading

0 comments on commit f1d35a6

Please sign in to comment.