Skip to content

Commit

Permalink
Merge pull request #255 from DChorn-ANS/dev
Browse files Browse the repository at this point in the history
Seperate Unused and Overused License Alerts
  • Loading branch information
KelvinTegelaar authored Jan 25, 2023
2 parents df38750 + 368db5c commit 9712267
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 39 deletions.
39 changes: 20 additions & 19 deletions AddAlert/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,26 @@ $Results = foreach ($Tenant in $tenants) {
'AllTenants'
}
$CompleteObject = @{
tenant = $tenant
tenantid = $TenantID
AdminPassword = [bool]$Request.body.AdminPassword
DefenderMalware = [bool]$Request.body.DefenderMalware
DefenderStatus = [bool]$Request.body.DefenderStatus
MFAAdmins = [bool]$Request.body.MFAAdmins
MFAAlertUsers = [bool]$Request.body.MFAAlertUsers
NewGA = [bool]$Request.body.NewGA
NewRole = [bool]$Request.body.NewRole
QuotaUsed = [bool]$Request.body.QuotaUsed
UnusedLicenses = [bool]$Request.body.UnusedLicenses
AppSecretExpiry = [bool]$Request.body.AppSecretExpiry
ApnCertExpiry = [bool]$Request.body.ApnCertExpiry
VppTokenExpiry = [bool]$Request.body.VppTokenExpiry
DepTokenExpiry = [bool]$Request.body.DepTokenExpiry
NoCAConfig = [bool]$Request.body.NoCAConfig
type = 'Alert'
RowKey = $TenantID
PartitionKey = 'Alert'
tenant = $tenant
tenantid = $TenantID
AdminPassword = [bool]$Request.body.AdminPassword
DefenderMalware = [bool]$Request.body.DefenderMalware
DefenderStatus = [bool]$Request.body.DefenderStatus
MFAAdmins = [bool]$Request.body.MFAAdmins
MFAAlertUsers = [bool]$Request.body.MFAAlertUsers
NewGA = [bool]$Request.body.NewGA
NewRole = [bool]$Request.body.NewRole
QuotaUsed = [bool]$Request.body.QuotaUsed
UnusedLicenses = [bool]$Request.body.UnusedLicenses
OverusedLicenses = [bool]$Request.body.OverusedLicenses
AppSecretExpiry = [bool]$Request.body.AppSecretExpiry
ApnCertExpiry = [bool]$Request.body.ApnCertExpiry
VppTokenExpiry = [bool]$Request.body.VppTokenExpiry
DepTokenExpiry = [bool]$Request.body.DepTokenExpiry
NoCAConfig = [bool]$Request.body.NoCAConfig
type = 'Alert'
RowKey = $TenantID
PartitionKey = 'Alert'
}

$Table = get-cipptable -TableName 'SchedulerConfig'
Expand Down
33 changes: 17 additions & 16 deletions ListAlertsQueue/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@ $QueuedApps = Get-AzDataTableEntity @Table -Filter $Filter

$CurrentStandards = foreach ($QueueFile in $QueuedApps) {
[PSCustomObject]@{
tenantName = $QueueFile.tenant
AdminPassword = [bool]$QueueFile.AdminPassword
DefenderMalware = [bool]$QueueFile.DefenderMalware
DefenderStatus = [bool]$QueueFile.DefenderStatus
MFAAdmins = [bool]$QueueFile.MFAAdmins
MFAAlertUsers = [bool]$QueueFile.MFAAlertUsers
NewGA = [bool]$QueueFile.NewGA
NewRole = [bool]$QueueFile.NewRole
QuotaUsed = [bool]$QueueFile.QuotaUsed
UnusedLicenses = [bool]$QueueFile.UnusedLicenses
AppSecretExpiry = [bool]$QueueFile.AppSecretExpiry
ApnCertExpiry = [bool]$QueueFile.ApnCertExpiry
VppTokenExpiry = [bool]$QueueFile.VppTokenExpiry
DepTokenExpiry = [bool]$QueueFile.DepTokenExpiry
NoCAConfig = [bool]$QueueFile.NoCAConfig
tenantId = $QueueFile.tenantid
tenantName = $QueueFile.tenant
AdminPassword = [bool]$QueueFile.AdminPassword
DefenderMalware = [bool]$QueueFile.DefenderMalware
DefenderStatus = [bool]$QueueFile.DefenderStatus
MFAAdmins = [bool]$QueueFile.MFAAdmins
MFAAlertUsers = [bool]$QueueFile.MFAAlertUsers
NewGA = [bool]$QueueFile.NewGA
NewRole = [bool]$QueueFile.NewRole
QuotaUsed = [bool]$QueueFile.QuotaUsed
UnusedLicenses = [bool]$QueueFile.UnusedLicenses
OverusedLicenses = [bool]$QueueFile.OverusedLicenses
AppSecretExpiry = [bool]$QueueFile.AppSecretExpiry
ApnCertExpiry = [bool]$QueueFile.ApnCertExpiry
VppTokenExpiry = [bool]$QueueFile.VppTokenExpiry
DepTokenExpiry = [bool]$QueueFile.DepTokenExpiry
NoCAConfig = [bool]$QueueFile.NoCAConfig
tenantId = $QueueFile.tenantid
}
}

Expand Down
28 changes: 24 additions & 4 deletions Scheduler_Alert/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,27 @@ try {
}
}
{ $_.'UnusedLicenses' -eq $true } {
try {
#$ConvertTable = Import-Csv Conversiontable.csv
$LicenseTable = Get-CIPPTable -TableName ExcludedLicenses
$ExcludedSkuList = Get-AzDataTableEntity @LicenseTable
New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscribedSkus' -tenantid $Tenant.tenant | ForEach-Object {
$skuid = $_
foreach ($sku in $skuid) {
if ($sku.skuId -in $ExcludedSkuList.GUID) { continue }
$PrettyName = ($ConvertTable | Where-Object { $_.GUID -eq $_.skuid }).'Product_Display_Name' | Select-Object -Last 1
if (!$PrettyName) { $PrettyName = $sku.skuPartNumber }
if ($sku.prepaidUnits.enabled - $sku.consumedUnits -gt 0) {
"$PrettyName has unused licenses. Using $($_.consumedUnits) of $($_.prepaidUnits.enabled)."
}
}
}
}
catch {

}
}
{ $_.'OverusedLicenses' -eq $true } {
try {
#$ConvertTable = Import-Csv Conversiontable.csv
$LicenseTable = Get-CIPPTable -TableName ExcludedLicenses
Expand All @@ -162,10 +183,9 @@ try {
foreach ($sku in $skuid) {
if ($sku.skuId -in $ExcludedSkuList.GUID) { continue }
$PrettyName = ($ConvertTable | Where-Object { $_.GUID -eq $sku.skuid }).'Product_Display_Name' | Select-Object -Last 1
if (!$PrettyName) { $PrettyName = $skuid.skuPartNumber }

if ($sku.prepaidUnits.enabled - $sku.consumedUnits -ne 0) {
"$PrettyName has unused licenses. Using $($sku.consumedUnits) of $($sku.prepaidUnits.enabled)."
if (!$PrettyName) { $PrettyName = $sku.skuPartNumber }
if ($sku.prepaidUnits.enabled - $sku.consumedUnits -lt 0) {
"$PrettyName has Overused licenses. Using $($_.consumedUnits) of $($_.prepaidUnits.enabled)."
}
}
}
Expand Down

0 comments on commit 9712267

Please sign in to comment.