Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup and bugfixes #1121

Merged
merged 4 commits into from
Sep 26, 2024
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
10 changes: 0 additions & 10 deletions ExecAlertsListAllTenants/function.json

This file was deleted.

10 changes: 0 additions & 10 deletions ExecIncidentsListAllTenants/function.json

This file was deleted.

10 changes: 0 additions & 10 deletions ExecOffboard_Mailboxpermissions/function.json

This file was deleted.

8 changes: 0 additions & 8 deletions ExecOffboard_Mailboxpermissions/run.ps1

This file was deleted.

10 changes: 0 additions & 10 deletions ExecSchedulerBillingRun/function.json

This file was deleted.

21 changes: 0 additions & 21 deletions ExecSchedulerBillingRun/run.ps1

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function Push-UploadApplication {
#For anyone that reads this, The maximum chunk size is 100MB for blob storage, so we can upload it as one part and just give it the single ID. Easy :)
$Upload = Invoke-RestMethod -Uri "$($AzFileUri.azureStorageUri)&comp=block&blockid=$id" -Method Put -Headers @{'x-ms-blob-type' = 'BlockBlob' } -InFile $inFile -ContentType 'application/octet-stream'
Write-Host "Upload data: $($Upload | ConvertTo-Json -Depth 10)"
$ConfirmUpload = Invoke-RestMethod -Uri "$($AzFileUri.azureStorageUri)&comp=blocklist" -Method Put -Body "<?xml version=`"1.0`" encoding=`"utf-8`"?><BlockList><Latest>$id</Latest></BlockList>"
$ConfirmUpload = Invoke-RestMethod -Uri "$($AzFileUri.azureStorageUri)&comp=blocklist" -Method Put -Body "<?xml version=`"1.0`" encoding=`"utf-8`"?><BlockList><Latest>$id</Latest></BlockList>" -ContentType 'application/xml'
Write-Host "Confirm Upload data: $($ConfirmUpload | ConvertTo-Json -Depth 10)"
$CommitReq = New-graphPostRequest -Uri "$($BaseURI)/$($NewApp.id)/microsoft.graph.win32lobapp/contentVersions/1/files/$($ContentReq.id)/commit" -Body $EncBody -Type POST -tenantid $tenant
Write-Host "Commit Request: $($CommitReq | ConvertTo-Json -Depth 10)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Input bindings are passed in via param block.
param( $QueueItem, $TriggerMetadata)
function Push-ExecAlertsListAllTenants {
<#
.FUNCTIONALITY
Entrypoint
#>
[CmdletBinding()]
param($Item)

# Write out the queue message and metadata to the information log.
Write-Host "PowerShell queue trigger function processed work item: $QueueItem"

Get-Tenants | ForEach-Object -Parallel {
$domainName = $_.defaultDomainName
Import-Module CIPPCore
$domainName = $Item.defaultDomainName
$Table = Get-CIPPTable -TableName 'cachealertsandincidents'

try {
Expand All @@ -21,7 +21,6 @@ Get-Tenants | ForEach-Object -Parallel {
PartitionKey = 'alert'
}
Add-CIPPAzDataTableEntity @Table -Entity $GraphRequest -Force | Out-Null

}

} catch {
Expand All @@ -46,7 +45,5 @@ Get-Tenants | ForEach-Object -Parallel {
Tenant = $domainName
}
Add-CIPPAzDataTableEntity @Table -Entity $GraphRequest -Force | Out-Null


}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Input bindings are passed in via param block.
param( $QueueItem, $TriggerMetadata)
function Push-ExecIncidentsListAllTenants {
<#
.FUNCTIONALITY
Entrypoint
#>
param(
$Item
)

# Write out the queue message and metadata to the information log.
Write-Host "PowerShell queue trigger function processed work item: $QueueItem"

Get-Tenants | ForEach-Object -Parallel {
$domainName = $_.defaultDomainName
Import-Module CIPPCore
$domainName = $Item.defaultDomainName
$Table = Get-CIPPTable -TableName 'cachealertsandincidents'

try {
Expand Down Expand Up @@ -43,7 +44,6 @@ Get-Tenants | ForEach-Object -Parallel {
Tenant = [string]$domainName
}
Add-CIPPAzDataTableEntity @Table -Entity $GraphRequest -Force | Out-Null


}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function Push-ExecOffboardingMailboxPermissions {
<#
.FUNCTIONALITY
Entrypoint
#>
param(
$Item
)
$Mailboxes = New-ExoRequest -tenantid $Item.TenantFilter -cmdlet 'get-mailbox' -Select UserPrincipalName
foreach ($Mailbox in $Mailboxes) {
Remove-CIPPMailboxPermissions -PermissionsLevel @('FullAccess', 'SendAs', 'SendOnBehalf') -userid $Mailbox.UserPrincipalName -AccessUser $Item.User -TenantFilter $Item.TenantFilter -APIName $APINAME -ExecutingUser $Item.executingUser
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Function Push-ListBasicAuthAllTenants {
<#
.FUNCTIONALITY
Entrypoint
#>
[CmdletBinding()]
param($Item)

$domainName = $Item.defaultDomainName

$currentTime = Get-Date -Format 'yyyy-MM-ddTHH:MM:ss'
$ts = (Get-Date).AddDays(-30)
$endTime = $ts.ToString('yyyy-MM-ddTHH:MM:ss')
$filters = "createdDateTime ge $($endTime)Z and createdDateTime lt $($currentTime)Z and (clientAppUsed eq 'AutoDiscover' or clientAppUsed eq 'Exchange ActiveSync' or clientAppUsed eq 'Exchange Online PowerShell' or clientAppUsed eq 'Exchange Web Services' or clientAppUsed eq 'IMAP4' or clientAppUsed eq 'MAPI Over HTTP' or clientAppUsed eq 'Offline Address Book' or clientAppUsed eq 'Outlook Anywhere (RPC over HTTP)' or clientAppUsed eq 'Other clients' or clientAppUsed eq 'POP3' or clientAppUsed eq 'Reporting Web Services' or clientAppUsed eq 'Authenticated SMTP' or clientAppUsed eq 'Outlook Service')"
try {
$GraphRequest = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/auditLogs/signIns?api-version=beta&filter=$($filters)" -tenantid $domainName -ErrorAction stop | Sort-Object -Unique -Property clientAppUsed | ForEach-Object {
@{
Tenant = $domainName
clientAppUsed = $_.clientAppUsed
userPrincipalName = $_.UserPrincipalName
RowKey = "$($_.UserPrincipalName)-$($_.clientAppUsed)"
PartitionKey = 'basicauth'
}
}
} catch {
$GraphRequest = @{
Tenant = $domainName
clientAppUsed = "Could not connect to Tenant: $($_.Exception.message)"
userPrincipalName = $domainName
RowKey = $domainName
PartitionKey = 'basicauth'
}
}
$Table = Get-CIPPTable -TableName cachebasicauth
Add-CIPPAzDataTableEntity @Table -Entity $GraphRequest -Force | Out-Null

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ Function Invoke-ExecExtensionSync {
Write-LogMessage -API 'Scheduler_Billing' -tenant 'none' -message 'Starting billing processing.' -sev Info
$Table = Get-CIPPTable -TableName Extensionsconfig
$Configuration = (Get-CIPPAzDataTableEntity @Table).config | ConvertFrom-Json -Depth 10

foreach ($ConfigItem in $Configuration.psobject.properties.name) {
switch ($ConfigItem) {
'Gradient' {
If ($Configuration.Gradient.enabled -and $Configuration.Gradient.BillingEnabled) {
Push-OutputBinding -Name gradientqueue -Value 'LetsGo'
$Results = [pscustomobject]@{'Results' = 'Successfully started Gradient Sync' }
$ProcessorQueue = Get-CIPPTable -TableName 'ProcessorQueue'
$ProcessorFunction = [PSCustomObject]@{
PartitionKey = 'Function'
RowKey = 'New-GradientServiceSyncRun'
FunctionName = 'New-GradientServiceSyncRun'
}
Add-AzDataTableEntity @ProcessorQueue -Entity $ProcessorFunction -Force
$Results = [pscustomobject]@{'Results' = 'Successfully queued Gradient Sync' }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ Function Invoke-ListUsers {
$Table = Get-CIPPTable -TableName 'cacheusers'
$Rows = Get-CIPPAzDataTableEntity @Table | Where-Object -Property Timestamp -GT (Get-Date).AddHours(-1)
if (!$Rows) {
$Queue = New-CippQueueEntry -Name 'Users' -Link '/identity/administration/users?customerId=AllTenants'
Push-OutputBinding -Name listusers -Value "users/$($userid)?`$top=999&`$select=$($selectlist -join ',')&`$filter=$GraphFilter&`$count=true"
[PSCustomObject]@{
Tenant = 'Loading data for all tenants. Please check back after the job completes'
QueueId = $Queue.RowKey
Message = 'This function has been deprecated for all users, please use ListGraphRequest instead'
}
} else {
$Rows.Data | ConvertFrom-Json | Select-Object $selectlist | ForEach-Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,22 @@ Function Invoke-ListBasicAuth {
$Table = Get-CIPPTable -TableName cachebasicauth
$Rows = Get-CIPPAzDataTableEntity @Table | Where-Object -Property Timestamp -GT (Get-Date).AddHours(-1)
if (!$Rows) {
Push-OutputBinding -Name Msg -Value (Get-Date).ToString()
$TenantList = Get-Tenants -IncludeErrors
$Queue = New-CippQueueEntry -Name 'Basic Auth - All Tenants' -TotalTasks ($TenantList | Measure-Object).Count
$InputObject = [PSCustomObject]@{
OrchestratorName = 'BasicAuthOrchestrator'
QueueFunction = @{
FunctionName = 'GetTenants'
TenantParams = @{
IncludeErrors = $true
}
QueueId = $Queue.RowKey
DurableFunction = 'ListBasicAuthAllTenants'
}
SkipLog = $true
}
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Depth 5 -Compress)

$GraphRequest = [PSCustomObject]@{
Tenant = 'Loading data for all tenants. Please check back in 10 minutes'
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,22 @@ Function Invoke-ExecAlertsList {
$Filter = "PartitionKey eq 'alert'"
$Rows = Get-CIPPAzDataTableEntity @Table -filter $Filter | Where-Object -Property Timestamp -GT (Get-Date).AddMinutes(-10)
if (!$Rows) {
Push-OutputBinding -Name alertqueue -Value (Get-Date).ToString()
$TenantList = Get-Tenants -IncludeErrors
$Queue = New-CippQueueEntry -Name 'Alerts List' -TotalTasks ($TenantList | Measure-Object).Count
$InputObject = [PSCustomObject]@{
OrchestratorName = 'AlertsList'
QueueFunction = [PSCustomObject]@{
FunctionName = 'GetTenants'
QueueId = $Queue.RowKey
TenantParams = @{
IncludeErrors = $true
}
DurableName = 'ExecAlertsAllTenants'
}
SkipLog = $true
} | ConvertTo-Json -Depth 10
Start-NewOrchestration -FunctionName CIPPOrchestrator -InputObject $InputObject

[PSCustomObject]@{
Waiting = $true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,21 @@ Function Invoke-ExecIncidentsList {
$Filter = "PartitionKey eq 'Incident'"
$Rows = Get-CIPPAzDataTableEntity @Table -filter $Filter | Where-Object -Property Timestamp -GT (Get-Date).AddMinutes(-10)
if (!$Rows) {
Push-OutputBinding -Name incidentqueue -Value (Get-Date).ToString()
$TenantList = Get-Tenants -IncludeErrors
$Queue = New-CippQueueEntry -Name 'Incidents - All Tenants' -Link '/security/reports/incident-report?customerId=AllTenants' -TotalTasks ($TenantList | Measure-Object).Count
$InputObject = [PSCustomObject]@{
OrchestratorName = 'IncidentOrchestrator'
QueueFunction = @{
FunctionName = 'GetTenants'
TenantParams = @{
IncludeErrors = $true
}
QueueId = $Queue.RowKey
DurableFunction = 'ExecIncidentListAllTenants'
}
SkipLog = $true
}
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Depth 5 -Compress)
[PSCustomObject]@{
Waiting = $true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Function Invoke-ListLicenses {
$Table = Get-CIPPTable -TableName cachelicenses
$Rows = Get-CIPPAzDataTableEntity @Table | Where-Object -Property Timestamp -GT (Get-Date).AddHours(-1)
if (!$Rows) {
#Push-OutputBinding -Name LicenseQueue -Value (Get-Date).ToString()
$GraphRequest = [PSCustomObject]@{
Tenant = 'Loading data for all tenants. Please check back in 1 minute'
License = 'Loading data for all tenants. Please check back in 1 minute'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Function Invoke-ListMFAUsers {
$TenantList = Get-Tenants -IncludeErrors
$Queue = New-CippQueueEntry -Name 'MFA Users - All Tenants' -Link '/identity/reports/mfa-report?customerId=AllTenants' -TotalTasks ($TenantList | Measure-Object).Count
Write-Information ($Queue | ConvertTo-Json)
#Push-OutputBinding -Name mfaqueue -Value $Queue.RowKey
$GraphRequest = [PSCustomObject]@{
UPN = 'Loading data for all tenants. Please check back in a few minutes'
}
Expand Down
16 changes: 0 additions & 16 deletions Modules/CIPPCore/Public/Entrypoints/Invoke-TestResults.ps1

This file was deleted.

Loading