summaryrefslogtreecommitdiff
path: root/windows
diff options
context:
space:
mode:
authorjhawkesworth <jhawkesworth@users.noreply.github.com>2016-06-16 20:32:53 +0100
committerMatt Davis <nitzmahone@users.noreply.github.com>2016-06-16 12:32:53 -0700
commit07ed6bbd56b7798714efef8af91b7d3fe744a895 (patch)
tree038db880f93b94253deccc8eac5a43530c3f7380 /windows
parent127ddc1f059ff5898cd56a4207989041a2d02379 (diff)
downloadansible-modules-extras-07ed6bbd56b7798714efef8af91b7d3fe744a895.tar.gz
Various fixes to win_regedit and documentation (#2436)
Diffstat (limited to 'windows')
-rw-r--r--windows/win_regedit.ps118
-rw-r--r--windows/win_regedit.py6
2 files changed, 18 insertions, 6 deletions
diff --git a/windows/win_regedit.ps1 b/windows/win_regedit.ps1
index f4975dea..723a6c7b 100644
--- a/windows/win_regedit.ps1
+++ b/windows/win_regedit.ps1
@@ -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)
}
diff --git a/windows/win_regedit.py b/windows/win_regedit.py
index 8845f8ce..d9de288e 100644
--- a/windows/win_regedit.py
+++ b/windows/win_regedit.py
@@ -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: