Azure / GuestConfiguration

PowerShell module for creating, testing, and publishing custom Guest Configuration
MIT License
5 stars 2 forks source link

New-GCPolicy needs an update to set "Mode" #279

Closed mgreenegit closed 1 year ago

mgreenegit commented 2 years ago

When the policy is DINE, we should help the customer select the mode.

Something like the following. The text needs improvement, it is just a suggestion.

$json = Get-Content $policy.Path | ConvertFrom-Json
$DscMode = [PSCustomObject]@{
    type = 'String'
    metadata = @{
        displayName = 'DSC Mode'
        description = 'Set the mode for Desired State Configuration to apply and then only monitor for drift, or apply and then automatically correct on drift.'
        portalReview = 'true'
    }
    allowedValues = @('ApplyAndMonitor', 'ApplyAndAutoCorrect')
    defaultValue = 'ApplyAndMonitor'
    }
$DscModeParam1 = [PSCustomObject]@{
    value = "[parameters('DscMode')]"
}
$DscModeParam2 = [PSCustomObject]@{
    type = 'string'
}
$json.properties.parameters | Add-Member -MemberType NoteProperty -Name DscMode -Value $DscMode
$json.properties.policyRule.then.details.deployment.properties.parameters | Add-Member -MemberType NoteProperty -Name DscMode -Value $DscModeParam1
$json.properties.policyRule.then.details.deployment.properties.template.parameters | Add-Member -MemberType NoteProperty -Name DscMode -Value $DscModeParam2
$json.properties.policyRule.then.details.deployment.properties.template.resources[0].properties.guestConfiguration.assignmentType = "[parameters('DscMode')]"
$json.properties.policyRule.then.details.deployment.properties.template.resources[1].properties.guestConfiguration.assignmentType = "[parameters('DscMode')]"
github-actions[bot] commented 2 years ago

This issue has not been updated within 14 days