DSC Class-based Resource with Flags Enum Property

Welcome Forums DSC (Desired State Configuration) DSC Class-based Resource with Flags Enum Property

This topic contains 1 reply, has 1 voice, and was last updated by

3 years, 7 months ago.

  • Author
  • #30040

    Points: 0
    Rank: Member

    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

    Points: 0
    Rank: Member

    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

The topic ‘DSC Class-based Resource with Flags Enum Property’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort