Skip to content

Commit

Permalink
Merge pull request #39 from KelvinTegelaar/dev
Browse files Browse the repository at this point in the history
[pull] dev from KelvinTegelaar:dev
  • Loading branch information
pull[bot] authored Jan 30, 2025
2 parents e5ddb2b + 3bbb746 commit 4b9e456
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Function Invoke-AddPolicy {
$displayname = $Request.Body.displayName
$description = $Request.Body.Description
$AssignTo = if ($Request.Body.AssignTo -ne 'on') { $Request.Body.AssignTo }
$Request.body.customGroup ? ($AssignTo = $Request.body.customGroup) : $null
$RawJSON = $Request.Body.RAWJson

$results = foreach ($Tenant in $tenants) {
Expand Down
2 changes: 1 addition & 1 deletion Modules/CIPPCore/Public/Set-CIPPAssignedPolicy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function Set-CIPPAssignedPolicy {
)
}
default {
Write-Host "We're supposed to assign a custom group. The group is $GroupName"
$GroupNames = $GroupName.Split(',')
$GroupIds = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/groups?$select=id,displayName&$top=999' -tenantid $TenantFilter | ForEach-Object {
$Group = $_
Expand Down Expand Up @@ -78,7 +79,6 @@ function Set-CIPPAssignedPolicy {
Write-LogMessage -user $ExecutingUser -API $APIName -message "Assigned $GroupName to Policy $PolicyId" -Sev 'Info' -tenant $TenantFilter
}
} catch {
#$ErrorMessage = Get-CippException -Exception $_
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
Write-LogMessage -user $ExecutingUser -API $APIName -message "Failed to assign $GroupName to Policy $PolicyId, using Platform $PlatformType and $Type. The error is:$ErrorMessage" -Sev 'Error' -tenant $TenantFilter -LogData $ErrorMessage
}
Expand Down
1 change: 1 addition & 0 deletions Modules/CIPPCore/Public/Set-CIPPIntunePolicy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ function Set-CIPPIntunePolicy {
if ($AssignTo) {
Write-Host "Assigning policy to $($AssignTo) with ID $($CreateRequest.id) and type $TemplateTypeURL for tenant $tenantFilter"
Write-Host "ID is $($CreateRequest.id)"

Set-CIPPAssignedPolicy -GroupName $AssignTo -PolicyId $CreateRequest.id -Type $TemplateTypeURL -TenantFilter $tenantFilter
}
return "Successfully $($PostType) policy for $($tenantFilter) with display name $($Displayname)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function Invoke-CIPPStandardGroupTemplate {
CAT
Templates
DISABLEDFEATURES
IMPACT
Medium
ADDEDCOMPONENT
Expand All @@ -29,7 +29,9 @@ function Invoke-CIPPStandardGroupTemplate {
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'GroupTemplate'

If ($Settings.remediate -eq $true) {

#Because the list name changed from TemplateList to groupTemplate by someone :@, we'll need to set it back to TemplateList
$Settings.groupTemplate ? ($Settings | Add-Member -NotePropertyName 'TemplateList' -NotePropertyValue $Settings.groupTemplate) : $null
Write-Host "Settings: $($Settings.TemplateList | ConvertTo-Json)"
foreach ($Template in $Settings.TemplateList) {
try {
$Table = Get-CippTable -tablename 'templates'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function Invoke-CIPPStandardIntuneTemplate {
MULTIPLE
True
DISABLEDFEATURES
IMPACT
High
ADDEDCOMPONENT
Expand All @@ -33,17 +33,19 @@ function Invoke-CIPPStandardIntuneTemplate {
If ($Settings.remediate -eq $true) {

Write-Host 'starting template deploy'
Write-Host "The full settings are $($Settings | ConvertTo-Json)"
$APINAME = 'Standards'
foreach ($Template in $Settings.TemplateList) {
foreach ($Template in $Settings) {
Write-Host "working on template deploy: $($Template | ConvertTo-Json)"
try {
$Table = Get-CippTable -tablename 'templates'
$Filter = "PartitionKey eq 'IntuneTemplate'"
$Request = @{body = $null }
$Request.body = (Get-CIPPAzDataTableEntity @Table -Filter $Filter | Where-Object -Property RowKey -Like "$($template.value)*").JSON | ConvertFrom-Json
$Request.body = (Get-CIPPAzDataTableEntity @Table -Filter $Filter | Where-Object -Property RowKey -Like "$($Template.TemplateList.value)*").JSON | ConvertFrom-Json
$displayname = $request.body.Displayname
$description = $request.body.Description
$RawJSON = $Request.body.RawJSON
$Template.customGroup ? ($Template.AssignTo = $Template.customGroup) : $null
Set-CIPPIntunePolicy -TemplateType $Request.body.Type -Description $description -DisplayName $displayname -RawJSON $RawJSON -AssignTo $Template.AssignTo -tenantFilter $Tenant

} catch {
Expand Down

0 comments on commit 4b9e456

Please sign in to comment.