Skip to content

Commit

Permalink
cleaned up standards deployment. New assigns via set-intunepolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar authored and OfficialEsco committed Aug 13, 2024
1 parent 8e14c16 commit 77b3401
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ function Invoke-CIPPStandardIntuneTemplate {
$RawJSON = $Request.body.RawJSON
$TemplateTypeURL = $Request.body.Type

Set-CIPPIntunePolicy -TemplateType $Request.body.Type -Description $description -DisplayName $displayname -RawJSON $RawJSON -AssignTo $null -tenantFilter $Tenant
Set-CIPPIntunePolicy -TemplateType $Request.body.Type -Description $description -DisplayName $displayname -RawJSON $RawJSON -AssignTo $Template.AssignedTo -tenantFilter $Tenant

#Legacy assign.
#Legacy assign, only required for older templates.
if ($Settings.AssignTo) {
Write-Host "Assigning Policy to $($Settings.AssignTo) the create ID is $($CreateRequest)"
if ($Settings.AssignTo -eq 'customGroup') { $Settings.AssignTo = $Settings.customGroup }
Expand All @@ -37,16 +37,6 @@ function Invoke-CIPPStandardIntuneTemplate {
}
}

if ($Template.AssignedTo) {
Write-Host "New: Assigning Policy to $($Template.AssignedTo) the create ID is $($CreateRequest)"
if ($ExistingID) {
Set-CIPPAssignedPolicy -PolicyId $ExistingID.id -TenantFilter $tenant -GroupName $Template.AssignedTo -Type $TemplateTypeURL
Write-LogMessage -API 'Standards' -tenant $tenant -message "Successfully updated Intune Template $PolicyName policy for $($Tenant)" -sev 'Info'
} else {
Set-CIPPAssignedPolicy -PolicyId $CreateRequest.id -TenantFilter $tenant -GroupName $Template.AssignedTo -Type $TemplateTypeURL
Write-LogMessage -API 'Standards' -tenant $tenant -message "Successfully created Intune Template $PolicyName policy for $($Tenant)" -sev 'Info'
}
}
} catch {
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to create or update Intune Template $PolicyName, Error: $ErrorMessage" -sev 'Error'
Expand Down

0 comments on commit 77b3401

Please sign in to comment.