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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Invoke-GetCippAlerts {
$PartitionKey = Get-Date -UFormat '%Y%m%d'
$Filter = "PartitionKey eq '{0}'" -f $PartitionKey
$Rows = Get-CIPPAzDataTableEntity @Table -Filter $Filter | Sort-Object TableTimestamp -Descending | Select-Object -First 10
$Role = ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Request.Headers.'x-ms-client-principal')) | ConvertFrom-Json).userRoles
$Role = Get-CippAccessRole -Request $Request

$CIPPVersion = $Request.Query.localversion
$Version = Assert-CippVersion -CIPPVersion $CIPPVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ function Invoke-ListStandardsCompare {
$Table = Get-CIPPTable -TableName 'CippStandardsReports'
$TenantFilter = $Request.Query.tenantFilter
if ($TenantFilter) {
$Table.Filter = "RowKey eq '{0}'" -f $TenantFilter
$Table.Filter = "PartitionKey eq '{0}'" -f $TenantFilter
}

$Results = Get-CIPPAzDataTableEntity @Table
$Standards = Get-CIPPAzDataTableEntity @Table

#in the results we have objects starting with "standards." All these have to be converted from JSON. Do not do this is its a boolean
$Results | ForEach-Object {
<#$Results | ForEach-Object {
$Object = $_
$Object.PSObject.Properties | ForEach-Object {
if ($_.Name -like 'standards_*') {
Expand All @@ -40,8 +40,43 @@ function Invoke-ListStandardsCompare {
$object.PSObject.Properties.Remove($_.Name)
}
}
}#>

$TenantStandards = @{}
$Results = [System.Collections.Generic.List[object]]::new()

foreach ($Standard in $Standards) {
# each standard is on their own row now, the field name is the RowKey and the value is in the Value field
$FieldName = $Standard.RowKey
$FieldValue = $Standard.Value
$Tenant = $Standard.PartitionKey
if ($FieldValue -is [System.Boolean]) {
$FieldValue = [bool]$FieldValue
} elseif ($FieldValue -like '*{*') {
$FieldValue = ConvertFrom-Json -InputObject $FieldValue -ErrorAction SilentlyContinue
} else {
$FieldValue = [string]$FieldValue
}

if (-not $TenantStandards.ContainsKey($Tenant)) {
$TenantStandards[$Tenant] = @{}
}
$TenantStandards[$Tenant][$FieldName] = @{
Value = $FieldValue
LastRefresh = $Standard.TimeStamp.ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
}
}

foreach ($Tenant in $TenantStandards.Keys) {
$TenantStandard = [PSCustomObject]@{
tenantFilter = $Tenant
}
foreach ($Field in $TenantStandards[$Tenant].Keys) {
$Value = $TenantStandards[$Tenant][$Field]
$TenantStandard | Add-Member -MemberType NoteProperty -Name $Field -Value $Value -Force
}
$Results.Add($TenantStandard)
}

Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@ function Invoke-listStandardTemplates {
Write-Host "$($RowKey) standard could not be loaded: $($_.Exception.Message)"
return
}
$Data | Add-Member -NotePropertyName 'GUID' -NotePropertyValue $_.GUID -Force

if (!$Data.excludedTenants) {
$Data | Add-Member -NotePropertyName 'excludedTenants' -NotePropertyValue @() -Force
}

if ($Data.excludedTenants -and $Data.excludedTenants -ne 'excludedTenants') {
$Data.excludedTenants = @($Data.excludedTenants)
} else {
$Data.excludedTenants = @()
if ($Data) {
$Data | Add-Member -NotePropertyName 'GUID' -NotePropertyValue $_.GUID -Force

if (!$Data.excludedTenants) {
$Data | Add-Member -NotePropertyName 'excludedTenants' -NotePropertyValue @() -Force
} else {
if ($Data.excludedTenants -and $Data.excludedTenants -ne 'excludedTenants') {
$Data.excludedTenants = @($Data.excludedTenants)
} else {
$Data.excludedTenants = @()
}
}
$Data
}
$Data
} | Sort-Object -Property templateName

if ($ID) { $Templates = $Templates | Where-Object GUID -EQ $ID }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ function Start-AuditLogSearchCreation {
$ConfigTable = Get-CippTable -TableName 'WebhookRules'
$ConfigEntries = Get-CIPPAzDataTableEntity @ConfigTable -Filter "PartitionKey eq 'Webhookv2'" | ForEach-Object {
$ConfigEntry = $_
$ConfigEntry.excludedTenants = $ConfigEntry.excludedTenants | ConvertFrom-Json
if (!$ConfigEntry.excludedTenants) {
$ConfigEntry | Add-Member -MemberType NoteProperty -Name 'excludedTenants' -Value @() -Force
} else {
$ConfigEntry.excludedTenants = $ConfigEntry.excludedTenants | ConvertFrom-Json
}
$ConfigEntry.Tenants = $ConfigEntry.Tenants | ConvertFrom-Json
$ConfigEntry
}
Expand Down
47 changes: 19 additions & 28 deletions Modules/CIPPCore/Public/Set-CIPPStandardsCompareField.ps1
Original file line number Diff line number Diff line change
@@ -1,49 +1,40 @@
function Set-CIPPStandardsCompareField {
[CmdletBinding(SupportsShouldProcess = $true)]
param (
$FieldName,
$FieldValue,
$TenantFilter
)
$Table = Get-CippTable -tablename 'CippStandardsReports'
$TenantName = Get-Tenants | Where-Object -Property defaultDomainName -EQ $Tenant

# Sanitize invalid c#/xml characters for Azure Tables
$FieldName = $FieldName.replace('standards.', 'standards_')
$FieldName = $FieldName.replace('IntuneTemplate.', 'IntuneTemplate_')
$FieldName = $FieldName -replace '-', '__'
$TenantName = Get-Tenants -TenantFilter $TenantFilter

if ($FieldValue -is [System.Boolean]) {
$fieldValue = [bool]$FieldValue
$FieldValue = [bool]$FieldValue
} elseif ($FieldValue -is [string]) {
$FieldValue = [string]$FieldValue
} else {
$FieldValue = ConvertTo-Json -Compress -InputObject @($FieldValue) -Depth 10 | Out-String
$FieldValue = [string]$FieldValue
}

$Existing = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq 'StandardReport' and RowKey eq '$($TenantName.defaultDomainName)'"
try {
if ($Existing) {
$Existing = $Existing | Select-Object * -ExcludeProperty ETag, TimeStamp | ConvertTo-Json -Depth 10 -Compress | ConvertFrom-Json -AsHashtable
$Existing[$FieldName] = $FieldValue
$Existing['LastRefresh'] = [string]$(Get-Date (Get-Date).ToUniversalTime() -UFormat '+%Y-%m-%dT%H:%M:%S.000Z')
$Existing = [PSCustomObject]$Existing
$Existing = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq '$($TenantName.defaultDomainName)' and RowKey eq '$($FieldName)'"

Add-CIPPAzDataTableEntity @Table -Entity $Existing -Force
} else {
$Result = @{
tenantFilter = "$($TenantName.defaultDomainName)"
GUID = "$($TenantName.customerId)"
RowKey = "$($TenantName.defaultDomainName)"
PartitionKey = 'StandardReport'
LastRefresh = [string]$(Get-Date (Get-Date).ToUniversalTime() -UFormat '+%Y-%m-%dT%H:%M:%S.000Z')
if ($PSCmdlet.ShouldProcess('CIPP Standards Compare', "Set field '$FieldName' to '$FieldValue' for tenant '$($TenantName.defaultDomainName)'")) {
try {
if ($Existing) {
$Existing.Value = $FieldValue
Add-CIPPAzDataTableEntity @Table -Entity $Existing -Force
} else {
$Result = [PSCustomObject]@{
PartitionKey = [string]$TenantName.defaultDomainName
RowKey = [string]$FieldName
Value = $FieldValue
}
Add-CIPPAzDataTableEntity @Table -Entity $Result -Force
}
$Result[$FieldName] = $FieldValue
Add-CIPPAzDataTableEntity @Table -Entity $Result -Force

Write-Information "Adding $FieldName to StandardCompare for $Tenant. content is $FieldValue"
} catch {
Write-Warning "Failed to add $FieldName to StandardCompare for $Tenant. content is $FieldValue - $($_.Exception.Message)"
}
Write-Information "Adding $FieldName to StandardCompare for $Tenant. content is $FieldValue"
} catch {
Write-Warning "Failed to add $FieldName to StandardCompare for $Tenant. content is $FieldValue - $($_.Exception.Message)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function Invoke-CIPPStandardGlobalQuarantineNotifications {
} else {
try {
if ($CurrentState.Name -eq 'DefaultGlobalPolicy') {
$null = New-ExoRequest -tenantid $Tenant -cmdlet 'New-QuarantinePolicy' -cmdParams @{ Name = 'DefaultGlobalTag'; QuarantinePolicyType = 'GlobalQuarantinePolicy'; EndUserSpamNotificationFrequency = [string]$WantedState.TotalHours }
$null = New-ExoRequest -tenantid $Tenant -cmdlet 'New-QuarantinePolicy' -cmdParams @{ Name = 'DefaultGlobalTag'; QuarantinePolicyType = 'GlobalQuarantinePolicy'; EndUserSpamNotificationFrequency = [string]$WantedState }
} else {
$null = New-ExoRequest -tenantid $Tenant -cmdlet 'Set-QuarantinePolicy' -cmdParams @{Identity = $CurrentState.Identity; EndUserSpamNotificationFrequency = [string]$WantedState }
}
Expand Down
2 changes: 1 addition & 1 deletion version_latest.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.0.2
8.0.3