Author Posts

September 24, 2015 at 8:51 am

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.

September 24, 2015 at 9:22 am

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