Fix #1107: Use Get-Attr in win_regedit
This commit is contained in:
parent
9b9464ab89
commit
6fed60c1bd
1 changed files with 8 additions and 51 deletions
|
@ -25,60 +25,17 @@ $params = Parse-Args $args;
|
||||||
$result = New-Object PSObject;
|
$result = New-Object PSObject;
|
||||||
Set-Attr $result "changed" $false;
|
Set-Attr $result "changed" $false;
|
||||||
|
|
||||||
If ($params.key)
|
$registryKey = Get-Attr -obj $params -name "key" -failifempty $true
|
||||||
{
|
$registryValue = Get-Attr -obj $params -name "value" -default $null
|
||||||
$registryKey = $params.key
|
$state = Get-Attr -obj $params -name "state" -validateSet "present","absent" -default "present"
|
||||||
}
|
$registryData = Get-Attr -obj $params -name "data" -default $null
|
||||||
Else
|
$registryDataType = Get-Attr -obj $params -name "datatype" -validateSet "binary","dword","expandstring","multistring","string","qword" -default "string"
|
||||||
{
|
|
||||||
Fail-Json $result "missing required argument: key"
|
|
||||||
}
|
|
||||||
|
|
||||||
If ($params.value)
|
If ($state -eq "present" -and $registryData -eq $null -and $registryValue -ne $null)
|
||||||
{
|
|
||||||
$registryValue = $params.value
|
|
||||||
}
|
|
||||||
Else
|
|
||||||
{
|
|
||||||
$registryValue = $null
|
|
||||||
}
|
|
||||||
|
|
||||||
If ($params.state)
|
|
||||||
{
|
|
||||||
$state = $params.state.ToString().ToLower()
|
|
||||||
If (($state -ne "present") -and ($state -ne "absent"))
|
|
||||||
{
|
|
||||||
Fail-Json $result "state is $state; must be present or absent"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Else
|
|
||||||
{
|
|
||||||
$state = "present"
|
|
||||||
}
|
|
||||||
|
|
||||||
If ($params.data)
|
|
||||||
{
|
|
||||||
$registryData = $params.data
|
|
||||||
}
|
|
||||||
ElseIf ($state -eq "present" -and $registryValue -ne $null)
|
|
||||||
{
|
{
|
||||||
Fail-Json $result "missing required argument: data"
|
Fail-Json $result "missing required argument: data"
|
||||||
}
|
}
|
||||||
|
|
||||||
If ($params.datatype)
|
|
||||||
{
|
|
||||||
$registryDataType = $params.datatype.ToString().ToLower()
|
|
||||||
$validRegistryDataTypes = "binary", "dword", "expandstring", "multistring", "string", "qword"
|
|
||||||
If ($validRegistryDataTypes -notcontains $registryDataType)
|
|
||||||
{
|
|
||||||
Fail-Json $result "type is $registryDataType; must be binary, dword, expandstring, multistring, string, or qword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Else
|
|
||||||
{
|
|
||||||
$registryDataType = "string"
|
|
||||||
}
|
|
||||||
|
|
||||||
Function Test-RegistryValueData {
|
Function Test-RegistryValueData {
|
||||||
Param (
|
Param (
|
||||||
[parameter(Mandatory=$true)]
|
[parameter(Mandatory=$true)]
|
||||||
|
|
Loading…
Reference in a new issue