Issue with dsc_resource string to string[]


#1

I am attempting to use the PowerShell DSC resource xSmbShare in a dsc_resource. It has a property that requires a powershell string array.

Using DSC directly, you would specify like this: FullAccess = @("User1")

so I attempt to use dsc_resource "" do property :FullAccess, "User1" but I get a powershell error when running the resource stating "cannot convert string to string"

So i attempted to modify this:
class WebsiteBindings
@bindings =
def initialize(bindings)
@bindings = bindings
end
def to_psobject()
bindings = Array.new()
@bindings.each do |b|
bindings.push("(new-ciminstance -classname MSFT_xWebBindingInformation -Namespace
root/microsoft/Windows/DesiredStateConfiguration -Property @{Protocol=#{b[:protocol]};IPAddress=#
{b[:ip]};Port=#{b[:port]}} -ClientOnly)")
end
"ciminstance[]"
end
end
bindings = WebsiteBindings.new([
{ protocol: 'HTTP', ip:'127.0.0.1', port: 8080},
{ protocol: 'HTTP', ip: '127.0.0.1', port: 8081} ])

To just create a powershell string array rather than an array of powershell ciminstances, but I am unable to get it to work.

Any suggestions?


#2

I have several DSC resources that I've used where certain properties have required array values. In these instances, I simply wrapped the values in brackets '[' ']' within the dsc_resource construct, which is the way to express array literals in Ruby. Have you given that a try?


#3

This has at least changed the error. Thank you for the help. Should have looked for the simple solution before the complex one.