dsccommunity / UpdateServicesDsc

This module contains community maintained DSC resources for deployment and configuration of Windows Server Update Services.
MIT License
31 stars 27 forks source link

DeleteInstallApprovalRule requires ruleId not Name #25

Closed berglundth closed 5 years ago

berglundth commented 6 years ago

On attempting to remove a rule I got this error:

VERBOSE: [SESTO869]: LCM:  [ Start  Resource ]  [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule]
VERBOSE: [SESTO869]: LCM:  [ Start  Test     ]  [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule]
VERBOSE: [SESTO869]:                            [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule] Identified WSUS
 server information: Microsoft.UpdateServices.Internal.BaseApi.UpdateServer
VERBOSE: [SESTO869]:                            [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule] Ensure test
failed
VERBOSE: [SESTO869]: LCM:  [ End    Test     ]  [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule]  in 0.4360
seconds.
VERBOSE: [SESTO869]: LCM:  [ Start  Set      ]  [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule]
VERBOSE: [SESTO869]:                            [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule] Failed during
creation of approval rule Default Automatic Approval Rule
VERBOSE: [SESTO869]: LCM:  [ End    Set      ]  [[UpdateServicesApprovalRule]RemoveDefaultApprovalRule]  in 0.2810
seconds.
PowerShell DSC resource MSFT_UpdateServicesApprovalRule  failed to execute Set-TargetResource functionality with error
message: Cannot convert argument "ruleId", with value: "Default Automatic Approval Rule", for "DeleteInstallApprovalRul
e" to type "System.Int32": "Cannot convert value "Default Automatic Approval Rule" to type "System.Int32". Error: "Inpu
t string was not in a correct format.""
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : SESTO869

When looking at the function signature of DeleteInstallApprovalRule it seems like it accepts the ruleId and not the name:

TypeName   : Microsoft.UpdateServices.Internal.BaseApi.UpdateServer
Name       : DeleteInstallApprovalRule
MemberType : Method
Definition : void DeleteInstallApprovalRule(int ruleId), void IUpdateServer.DeleteInstallApprovalRule(int ruleId)

And here's the calling code DSCResources/MSFT_UpdateServicesApprovalRule/MSFT_UpdateServicesApprovalRule.psm1 - Row 242

                "Absent"
                {
                    $WsusServer.DeleteInstallApprovalRule($Name)
                }