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
daveroyer authored Jun 3, 2024
2 parents 37b4252 + 49ebb8b commit d94eeac
Show file tree
Hide file tree
Showing 328 changed files with 3,025 additions and 1,827 deletions.
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)
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)
}
}
37 changes: 37 additions & 0 deletions Modules/CIPPCore/Public/Authentication/Get-CIPPHttpFunctions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function Get-CIPPHttpFunctions {
Param(
[switch]$ByRole,
[switch]$ByRoleGroup
)

try {
$Functions = Get-Command -Module CippCore | Where-Object { $_.Visibility -eq 'Public' -and $_.Name -match 'Invoke-*' }
$Results = foreach ($Function in $Functions) {
$Help = Get-Help $Function
if ($Help.Functionality -ne 'Entrypoint') { continue }
[PSCustomObject]@{
Function = $Function.Name
Role = $Help.Role
}
}

if ($ByRole.IsPresent -or $ByRoleGroup.IsPresent) {
$Results = $Results | Group-Object -Property Role | Select-Object -Property @{l = 'Permission'; e = { $_.Name -eq '' ? 'None' : $_.Name } }, Count, @{l = 'Functions'; e = { $_.Group.Function -replace 'Invoke-' } } | Sort-Object -Property Permission

if ($ByRoleGroup.IsPresent) {
$RoleGroup = @{}
foreach ($Permission in $Results) {
$PermSplit = $Permission.Permission -split '\.'
if ($PermSplit.Count -ne 3) { continue }
if ($RoleGroup[$PermSplit[0]] -eq $null) { $RoleGroup[$PermSplit[0]] = @{} }
if ($RoleGroup[$PermSplit[0]][$PermSplit[1]] -eq $null) { $RoleGroup[$PermSplit[0]][$PermSplit[1]] = @{} }
$RoleGroup[$PermSplit[0]][$PermSplit[1]][$PermSplit[2]] = @($Permission.Functions)
}
$Results = $RoleGroup
}
}
$Results
} catch {
"Function Error $($_.Exception.Message): $($_.InvocationInfo.PositionMessage)"
}
}
Loading

0 comments on commit d94eeac

Please sign in to comment.