mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
win_security_policy: Allow setting a value to empty (#42051)
* win_security_policy: allow removing values (resolves #40869) * Removing warning * Adding test for remove policy setting * Fixing string comparison * Make idempotent * Adding idempotency and diff test * added changelog fragment
This commit is contained in:
parent
b2527c55c3
commit
dc32842573
3 changed files with 59 additions and 0 deletions
|
@ -169,6 +169,8 @@ if ($secedit_ini.$section.ContainsKey($key)) {
|
|||
$secedit_ini.$section.$key = $value
|
||||
$will_change = $true
|
||||
}
|
||||
} elseif ([string]$value -eq "") {
|
||||
# Value is requested to be removed, and has already been removed, do nothing
|
||||
} else {
|
||||
if ($diff_mode) {
|
||||
$result.diff.prepared = @"
|
||||
|
@ -194,6 +196,8 @@ if ($will_change -eq $true) {
|
|||
if ($new_value -cne $value) {
|
||||
Fail-Json $result "Failed to change the value for key '$key' in section '$section', the value is still $new_value"
|
||||
}
|
||||
} elseif ([string]$value -eq "") {
|
||||
# Value was empty, so OK if no longer in the result
|
||||
} else {
|
||||
Fail-Json $result "The key '$key' in section '$section' is not a valid key, cannot set this value"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue