Forum Discussion
mmatec01
3 years agoNeophyte
Well. Mike. Thank you for couple of suggested workarounds. I don't want to use groovy in this particular DS. By the way if groovy can ingest special characters without scrubbing them, so should PowerShell. That's my point in here, in that PowerShell scripting should be a first-class citizen just like groovy is. Isn't the JVM that's running under the hood and parses both the groovy and PowerShell?
Back to this issue. I ran some tests and now I found a workaround solution.
- Declaring variable with $my_custom_device_property = '##MY.CUSTOM.PROP##' statement does not work if the value contains single quote. No surprise there.
- Declaring variable using here-string syntax (from above post) does not work either for the same reason.
-
Declaring variable by prefixing it by API GET call - which fetches said property works! For the simple reason that now you can check and sanitize the API result output before you assign it to variable. Like this:
$my_custom_device_property = (Get-Device_Property /device/devices/${device_id}/properties/${device_prop_name}) -replace "'",''
Note to self - go back to your scripts and change the simple assignments to API get function for the properties you can not control their contents.
Related Content
- 6 months ago
- 8 months ago