1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Various fixes to win_regedit and documentation (#2436)

This commit is contained in:
jhawkesworth 2016-06-16 20:32:53 +01:00 committed by Matt Clay
parent 5d63d0b8d1
commit b32c550e22
2 changed files with 18 additions and 6 deletions

View file

@ -42,6 +42,13 @@ If ($state -eq "present" -and $registryData -eq $null -and $registryValue -ne $n
Fail-Json $result "missing required argument: data"
}
# check the registry key is in powershell ps-drive format: HKLM, HKCU, HKU, HKCR, HCCC
If (-not ($registryKey -match "^H[KC][CLU][MURC]{0,1}:\\"))
{
Fail-Json $result "key: $registryKey is not a valid powershell path, see module documentation for examples."
}
Function Test-RegistryValueData {
Param (
[parameter(Mandatory=$true)]
@ -58,8 +65,8 @@ Function Test-RegistryValueData {
}
}
# Returns rue if registry data matches.
# Handles binary and string registry data
# Returns true if registry data matches.
# Handles binary, integer(dword) and string registry data
Function Compare-RegistryData {
Param (
[parameter(Mandatory=$true)]
@ -67,15 +74,14 @@ Function Compare-RegistryData {
[parameter(Mandatory=$true)]
[AllowEmptyString()]$DifferenceData
)
$refType = $ReferenceData.GetType().Name
if ($refType -eq "String" ) {
if ($ReferenceData -is [String] -or $ReferenceData -is [int]) {
if ($ReferenceData -eq $DifferenceData) {
return $true
} else {
return $false
}
} elseif ($refType -eq "Object[]") {
} elseif ($ReferenceData -is [Object[]]) {
if (@(Compare-Object $ReferenceData $DifferenceData -SyncWindow 0).Length -eq 0) {
return $true
} else {
@ -118,7 +124,7 @@ else
}
if($registryDataType -eq "binary" -and $registryData -ne $null -and $registryData.GetType().Name -eq 'String') {
if($registryDataType -eq "binary" -and $registryData -ne $null -and $registryData -is [String]) {
$registryData = Convert-RegExportHexStringToByteArray($registryData)
}

View file

@ -126,6 +126,12 @@ EXAMPLES = '''
key: HKCU:\Software\MyCompany
value: hello
state: absent
# Ensure registry paths containing spaces are quoted.
# Creates Registry Key called 'My Company'.
win_regedit:
key: 'HKCU:\Software\My Company'
'''
RETURN = '''
data_changed: