Skip to content

Commit 461cf13

Browse files
authored
Merge pull request #94 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents bd64968 + 8e53de2 commit 461cf13

File tree

130 files changed

+3496
-3024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+3496
-3024
lines changed

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ insert_final_newline = true
88

99
[*.{ps1, psd1, psm1}]
1010
indent_size = 4
11-
end_of_line = crlf
11+
end_of_line = lf
1212
trim_trailing_whitespace = true
1313

1414
[*.json]
1515
indent_size = 2
16-
end_of_line = crlf
16+
end_of_line = lf
1717
trim_trailing_whitespace = true
1818

1919
[*.{md, txt}]

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
* text=lf
2+
3+
*.txt text eol=crlf
4+
*.md text eol=crlf
5+
6+
*.ps1 text eol=lf
7+
*.psd1 text eol=lf
8+
*.psm1 text eol=lf
9+
10+
*.json text eol=lf
11+
12+
*.png binary
13+
*.jpg binary

Modules/CIPPCore/Public/Add-CIPPAzDataTableEntity.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,18 @@ function Add-CIPPAzDataTableEntity {
137137

138138
foreach ($row in $rows) {
139139
Write-Information "current entity is $($row.RowKey) with $($row.PartitionKey). Our size is $([System.Text.Encoding]::UTF8.GetByteCount($($row | ConvertTo-Json -Compress)))"
140-
Add-AzDataTableEntity -Context $Context -Force:$Force -CreateTableIfNotExists:$CreateTableIfNotExists -Entity $row
140+
$NewRow = [PSCustomObject]$row
141+
Add-AzDataTableEntity -Context $Context -Force:$Force -CreateTableIfNotExists:$CreateTableIfNotExists -Entity $NewRow
141142
}
142143
} else {
143-
Add-AzDataTableEntity -Context $Context -Force:$Force -CreateTableIfNotExists:$CreateTableIfNotExists -Entity $SingleEnt
144+
$NewEnt = [PSCustomObject]$SingleEnt
145+
Add-AzDataTableEntity -Context $Context -Force:$Force -CreateTableIfNotExists:$CreateTableIfNotExists -Entity $NewEnt
144146
}
145147

146148
} catch {
147149
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
150+
Write-Warning ("AzBobbyTables Error")
151+
Write-Information ($SingleEnt | ConvertTo-Json)
148152
throw "Error processing entity: $ErrorMessage Linenumber: $($_.InvocationInfo.ScriptLineNumber)"
149153
}
150154
} else {

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Graph Requests/Push-ListGraphRequestQueue.ps1

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ function Push-ListGraphRequestQueue {
2121
Write-Information "Queue Table: $TableName"
2222
$Table = Get-CIPPTable -TableName $TableName
2323

24-
$Filter = "PartitionKey eq '{0}' and Tenant eq '{1}'" -f $PartitionKey, $Item.TenantFilter
24+
$Filter = "PartitionKey eq '{0}' and (RowKey eq '{1}' or OriginalEntityId eq '{1}')" -f $PartitionKey, $Item.TenantFilter
2525
Write-Information "Filter: $Filter"
26-
$Existing = Get-CIPPAzDataTableEntity @Table -Filter $Filter -Property PartitionKey, RowKey
26+
$Existing = Get-CIPPAzDataTableEntity @Table -Filter $Filter -Property PartitionKey, RowKey, OriginalEntityId
2727
if ($Existing) {
2828
$null = Remove-AzDataTableEntity -Force @Table -Entity $Existing
2929
}
@@ -41,26 +41,25 @@ function Push-ListGraphRequestQueue {
4141
$RawGraphRequest = try {
4242
Get-GraphRequestList @GraphRequestParams
4343
} catch {
44+
$CippException = Get-CippException -Exception $_.Exception
4445
[PSCustomObject]@{
4546
Tenant = $Item.TenantFilter
46-
CippStatus = "Could not connect to tenant. $($_.Exception.message)"
47+
CippStatus = "Could not connect to tenant. $($CippException.NormalizedMessage)"
48+
CippException = [string]($CippException | ConvertTo-Json -Depth 10 -Compress)
4749
}
4850
}
49-
$GraphResults = foreach ($Request in $RawGraphRequest) {
50-
$Json = ConvertTo-Json -Depth 10 -Compress -InputObject $Request
51-
$RowKey = $Request.id ?? (New-Guid).Guid
52-
[PSCustomObject]@{
53-
Tenant = [string]$Item.TenantFilter
54-
QueueId = [string]$Item.QueueId
55-
QueueType = [string]$Item.QueueType
56-
RowKey = [string]$RowKey
57-
PartitionKey = [string]$PartitionKey
58-
Data = [string]$Json
59-
}
51+
$Json = ConvertTo-Json -Depth 10 -Compress -InputObject $RawGraphRequest
52+
$GraphResults = [PSCustomObject]@{
53+
PartitionKey = [string]$PartitionKey
54+
RowKey = [string]$Item.TenantFilter
55+
QueueId = [string]$Item.QueueId
56+
QueueType = [string]$Item.QueueType
57+
Data = [string]$Json
6058
}
6159
Add-CIPPAzDataTableEntity @Table -Entity $GraphResults -Force | Out-Null
6260
} catch {
63-
Write-Information "Queue Error: $($_.Exception.Message)"
61+
Write-Warning "Queue Error: $($_.Exception.Message)"
62+
#Write-Information ($GraphResults | ConvertTo-Json -Depth 10 -Compress)
6463
throw $_
6564
}
6665
}

Modules/CIPPCore/Public/Get-CIPPAzDatatableEntity.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@ function Get-CIPPAzDataTableEntity {
2323
}
2424
if (-not $mergedResults[$partitionKey].ContainsKey($entityId)) {
2525
$mergedResults[$partitionKey][$entityId] = @{
26-
Parts = New-Object 'System.Collections.ArrayList'
26+
Parts = [System.Collections.Generic.List[object]]::new()
2727
}
2828
}
29-
$mergedResults[$partitionKey][$entityId]['Parts'].Add($entity) > $null
29+
$mergedResults[$partitionKey][$entityId]['Parts'].Add($entity)
3030
} else {
3131
$partitionKey = $entity.PartitionKey
3232
if (-not $mergedResults.ContainsKey($partitionKey)) {
3333
$mergedResults[$partitionKey] = @{}
3434
}
3535
$mergedResults[$partitionKey][$entity.RowKey] = @{
3636
Entity = $entity
37-
Parts = New-Object 'System.Collections.ArrayList'
37+
Parts = [System.Collections.Generic.List[object]]::new()
3838
}
3939
}
4040
}
4141

42-
$finalResults = @()
42+
$finalResults = [System.Collections.Generic.List[object]]::new()
4343
foreach ($partitionKey in $mergedResults.Keys) {
4444
foreach ($entityId in $mergedResults[$partitionKey].Keys) {
4545
$entityData = $mergedResults[$partitionKey][$entityId]
46-
if ($entityData.Parts.Count -gt 0) {
46+
if (($entityData.Parts | Measure-Object).Count -gt 0) {
4747
$fullEntity = [PSCustomObject]@{}
4848
$parts = $entityData.Parts | Sort-Object PartIndex
4949
foreach ($part in $parts) {
@@ -60,9 +60,9 @@ function Get-CIPPAzDataTableEntity {
6060
$fullEntity | Add-Member -MemberType NoteProperty -Name 'PartitionKey' -Value $parts[0].PartitionKey -Force
6161
$fullEntity | Add-Member -MemberType NoteProperty -Name 'RowKey' -Value $entityId -Force
6262
$fullEntity | Add-Member -MemberType NoteProperty -Name 'Timestamp' -Value $parts[0].Timestamp -Force
63-
$finalResults = $finalResults + @($fullEntity)
63+
$finalResults.Add($fullEntity)
6464
} else {
65-
$finalResults = $finalResults + @($entityData.Entity)
65+
$FinalResults.Add($entityData.Entity)
6666
}
6767
}
6868
}

Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ function Get-GraphRequestList {
138138
$Table = Get-CIPPTable -TableName $TableName
139139
$Timestamp = (Get-Date).AddHours(-1).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ss.fffK')
140140
if ($TenantFilter -eq 'AllTenants') {
141-
$Filter = "PartitionKey eq '{0}' and QueueType eq 'AllTenants' and Timestamp ge datetime'{1}'" -f $PartitionKey, $Timestamp
141+
$Filter = "PartitionKey eq '{0}' and Timestamp ge datetime'{1}'" -f $PartitionKey, $Timestamp
142142
} else {
143-
$Filter = "PartitionKey eq '{0}' and Tenant eq '{1}' and Timestamp ge datetime'{2}'" -f $PartitionKey, $TenantFilter, $Timestamp
143+
$Filter = "PartitionKey eq '{0}' and (RowKey eq '{1}' or OriginalEntityId eq '{1}') and Timestamp ge datetime'{2}'" -f $PartitionKey, $TenantFilter, $Timestamp
144144
}
145145
$Rows = Get-CIPPAzDataTableEntity @Table -Filter $Filter
146146
$Type = 'Cache'
@@ -337,8 +337,16 @@ function Get-GraphRequestList {
337337
}
338338
}
339339
} else {
340-
$Rows | ForEach-Object {
341-
$_.Data | ConvertFrom-Json
340+
foreach ($Row in $Rows) {
341+
if ($Row.Data) {
342+
try {
343+
$Row.Data | ConvertFrom-Json -ErrorAction Stop
344+
} catch {
345+
Write-Warning "Could not convert data to JSON: $($_.Exception.Message)"
346+
#Write-Information ($Row | ConvertTo-Json)
347+
continue
348+
}
349+
}
342350
}
343351
}
344352
}

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardActivityBasedTimeout.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ function Invoke-CIPPStandardActivityBasedTimeout {
1919
{"type":"autoComplete","multiple":false,"creatable":false,"label":"Select value","name":"standards.ActivityBasedTimeout.timeout","options":[{"label":"1 Hour","value":"01:00:00"},{"label":"3 Hours","value":"03:00:00"},{"label":"6 Hours","value":"06:00:00"},{"label":"12 Hours","value":"12:00:00"},{"label":"24 Hours","value":"1.00:00:00"}]}
2020
IMPACT
2121
Medium Impact
22+
ADDEDDATE
23+
2022-04-13
2224
POWERSHELLEQUIVALENT
2325
Portal or Graph API
2426
RECOMMENDEDBY

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAddDKIM.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ function Invoke-CIPPStandardAddDKIM {
1717
ADDEDCOMPONENT
1818
IMPACT
1919
Low Impact
20+
ADDEDDATE
21+
2023-03-14
2022
POWERSHELLEQUIVALENT
2123
New-DkimSigningConfig and Set-DkimSigningConfig
2224
RECOMMENDEDBY

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAnonReportDisable.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ function Invoke-CIPPStandardAnonReportDisable {
1616
ADDEDCOMPONENT
1717
IMPACT
1818
Low Impact
19+
ADDEDDATE
20+
2021-11-16
1921
POWERSHELLEQUIVALENT
2022
Update-MgBetaAdminReportSetting -BodyParameter @{displayConcealedNames = \$true}
2123
RECOMMENDEDBY

0 commit comments

Comments
 (0)