forked from KelvinTegelaar/CIPP-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
957aefc
commit 880f8c8
Showing
1 changed file
with
18 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ function Set-CIPPIntunePolicy { | |
$CheckExististing = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/deviceAppManagement/$TemplateTypeURL" -tenantid $tenantFilter | ||
if ($displayname -in $CheckExististing.displayName) { | ||
$PostType = 'edited' | ||
$ExistingID = $CheckExististing | Where-Object -Property displayName -EQ $PolicyName | ||
$ExistingID = $CheckExististing | Where-Object -Property displayName -EQ $DisplayName | ||
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceAppManagement/$TemplateTypeURL/$($ExistingID.Id)" -tenantid $tenantFilter -type PATCH -body $RawJSON | ||
} else { | ||
$PostType = 'added' | ||
|
@@ -32,18 +32,18 @@ function Set-CIPPIntunePolicy { | |
$TemplateTypeURL = 'deviceCompliancePolicies' | ||
$CheckExististing = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter | ||
$JSON = $RawJSON | ConvertFrom-Json | Select-Object * -ExcludeProperty id, createdDateTime, lastModifiedDateTime, version, '[email protected]', '@odata.context' | ||
$JSON.scheduledActionsForRule = @($JSON.scheduledActionsForRule | Select-Object * -ExcludeProperty '[email protected]') | ||
$RawJSON = ConvertTo-Json -InputObject $JSON -Depth 20 -Compress | ||
Write-Host $RawJSON | ||
if ($displayname -in $CheckExististing.displayName) { | ||
$PostType = 'edited' | ||
$ExistingID = $CheckExististing | Where-Object -Property displayName -EQ $PolicyName | ||
$ExistingID = $CheckExististing | Where-Object -Property displayName -EQ $DisplayName | ||
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL/$($ExistingID.Id)" -tenantid $tenantFilter -type PATCH -body $RawJSON | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Updated policy $($PolicyName) to template defaults" -Sev 'info' | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Updated policy $($DisplayName) to template defaults" -Sev 'info' | ||
} else { | ||
$PostType = 'added' | ||
$JSON.scheduledActionsForRule = @($JSON.scheduledActionsForRule | Select-Object * -ExcludeProperty '[email protected]') | ||
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter -type POST -body $RawJSON | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Added policy $($PolicyName) via template" -Sev 'info' | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Added policy $($DisplayName) via template" -Sev 'info' | ||
} | ||
} | ||
'Admin' { | ||
|
@@ -78,44 +78,44 @@ function Set-CIPPIntunePolicy { | |
$CheckExististing = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter | ||
if ($PolicyFile.displayName -in $CheckExististing.displayName) { | ||
$PostType = 'edited' | ||
$ExistingID = $CheckExististing | Where-Object -Property displayName -EQ $PolicyName | ||
$ExistingID = $CheckExististing | Where-Object -Property displayName -EQ $DisplayName | ||
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL/$($ExistingID.Id)" -tenantid $tenantFilter -type PATCH -body $RawJSON | ||
$CreateRequest = $CheckExististing | Where-Object -Property displayName -EQ $PolicyName | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Updated policy $($PolicyName) to template defaults" -Sev 'info' | ||
$CreateRequest = $CheckExististing | Where-Object -Property displayName -EQ $DisplayName | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Updated policy $($DisplayName) to template defaults" -Sev 'info' | ||
} else { | ||
$PostType = 'added' | ||
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter -type POST -body $RawJSON | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Added policy $($PolicyName) via template" -Sev 'info' | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Added policy $($DisplayName) via template" -Sev 'info' | ||
|
||
} | ||
} | ||
'Catalog' { | ||
$TemplateTypeURL = 'configurationPolicies' | ||
$PolicyName = ($RawJSON | ConvertFrom-Json).Name | ||
$DisplayName = ($RawJSON | ConvertFrom-Json).Name | ||
$CheckExististing = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter | ||
if ($PolicyName -in $CheckExististing.name) { | ||
$ExistingID = $CheckExististing | Where-Object -Property Name -EQ $PolicyName | ||
if ($DisplayName -in $CheckExististing.name) { | ||
$ExistingID = $CheckExististing | Where-Object -Property Name -EQ $DisplayName | ||
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL/$($ExistingID.Id)" -tenantid $tenantFilter -type PUT -body $RawJSON | ||
$CreateRequest = $CheckExististing | Where-Object -Property Name -EQ $PolicyName | ||
$CreateRequest = $CheckExististing | Where-Object -Property Name -EQ $DisplayName | ||
$PostType = 'edited' | ||
} else { | ||
$PostType = 'added' | ||
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter -type POST -body $RawJSON | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Added policy $($PolicyName) via template" -Sev 'info' | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Added policy $($DisplayName) via template" -Sev 'info' | ||
} | ||
} | ||
'windowsDriverUpdateProfiles' { | ||
$TemplateTypeURL = 'windowsDriverUpdateProfiles' | ||
$PolicyName = ($RawJSON | ConvertFrom-Json).Name | ||
$DisplayName = ($RawJSON | ConvertFrom-Json).Name | ||
$CheckExististing = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter | ||
if ($PolicyName -in $CheckExististing.name) { | ||
if ($DisplayName -in $CheckExististing.name) { | ||
$PostType = 'edited' | ||
$ExistingID = $CheckExististing | Where-Object -Property Name -EQ $PolicyName | ||
$ExistingID = $CheckExististing | Where-Object -Property Name -EQ $DisplayName | ||
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL/$($ExistingID.Id)" -tenantid $tenantFilter -type PUT -body $RawJSON | ||
} else { | ||
$PostType = 'added' | ||
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL" -tenantid $tenantFilter -type POST -body $RawJSON | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Added policy $($PolicyName) via template" -Sev 'info' | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantFilter) -message "Added policy $($DisplayName) via template" -Sev 'info' | ||
} | ||
} | ||
|
||
|