DSC Class-based Resource with Flags Enum Property

This topic contains 1 reply, has 1 voice, and was last updated by Profile photo of Adam Weigert Adam Weigert 1 year, 1 month ago.

  • Author
  • #30040
    Profile photo of Adam Weigert
    Adam Weigert

    If I use an enum for a property that has the Flags attribute, e.g. System.Security.AccessControl.RegistryRights, as a property DSC won't let me define the flags values or even the actual value, it is forcing it to be one value from the entire enum.

    Anyone know of a workaround for this or a connect issue that I could up vote?

    xMyResource Resource { Rights = 'SetValue, CreateSubKey, ReadKey' }

    At least one of the values 'SetValue, CreateSubKey, ReadKey' is not supported or valid for property 'Rights' on class 'xRegistryPermission'. Please specify only supported values:
    QueryValues, SetValue, CreateSubKey, EnumerateSubKeys, Notify, CreateLink, Delete, ReadPermissions, WriteKey, ExecuteKey, ReadKey, ChangePermissions, TakeOwnership, FullControl.

  • #30042
    Profile photo of Adam Weigert
    Adam Weigert

    Workaround I'm using currently is to turn the property into an array of values, then flatten the flags attribute like this:

    [RegistryRights]$Value = 0
    $Rights.ForEach{$Value += $_}

    Makes it slightly less pretty but just as effective for the time being.

    I've opened a connect issue here: https://connect.microsoft.com/PowerShell/feedbackdetail/view/1831074/dsc-resource-property-with-flags-enum

You must be logged in to reply to this topic.