cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Azmaeus
Level 6

CustomActionData passed to Powershell parses incorrectly

I have a powershell script that runs in the Deferred execution sequence and requires a few MSI Properties to be passed to it. When I need multiple properties for a CA in deferred action, I always use key/value pairs; for example in InstallScript when I need multiple MSI properties the CAD will have "/Property1=[Property1] /Property2=[Property2]" then inside the script I have a function that parses these key/value pairs and sets the variables inside my script, so instead of expecting the order of passed parameters I can simply gather them by name. This function works well in InstallScript.

I now need to pass multiple properties to a Powershell CA, and I thought I'd be clever. Rather than continuing the "/Property1=[Property1] /Property2=[Property2]" format, I decided to use "Property1 = [Property1] `n Property2 = [Property2]" which can then be passed directly to ConvertFrom-StringData to create a hash table for me. Then I can get something like this:

$MyHashTable.Property1
MyProperty1Info

$MyHashTable.Property2
My Property2 Information

When I run the powershell script on its own (replacing the Get-Property cmdlet with a set string variable of "Property1 = MyProperty1Info `n Property2 = My Property2 Information") the string is parsed correctly, and I'm left with a working hash table with the information I need each in its own. When I run it in a deferred custom action however, the `n doesn't seem to get recognized so I'm left with a hash table and a single entry, like so:

$MyHashTable.Property1
MyProperty1Info `n Property2 = My Property2 Information

As you can see, it's still pulling the CAD as expected, and the hash table is still created, only the `n isn't parsed correctly so instead of multiple pairs it only sees one with the value being everything after the first =.

I can get by with a string.split for now, but I'd really like to figure this out.

Labels (1)
0 Kudos
0 Replies