Using [array] in a class based DSC resource - class

I have been creating a few class based custom DSC resources and I am running into the following issue:
Whenever I try to use an array as input for my resource, I get an error.
For example
DscProperty(Mandatory)]
[array]$Products
Would result in the following error when I try to create a MOF file using my resource:
Write-NodeMOFFile : Invalid MOF definition for node 'nodename':
Exceptioncalling "ValidateInstanceText" with "1" argument(s):
"Convert property 'Products' value from type 'STRING[]' to type 'INSTANCE' failed.
The input object for $Products would be (for example):
$Products = #("Windows server 2012", "Windows SQL Server", "Windows 8.1")
I honestly have no idea why the Write-NodeMOFFile function would try to convert the array (it should not need converting, right?) and even if it needed to be converted - why would it convert an array from STRING[] to INSTANCE?
Anyone has a clue as to why this happens?
The only way I got it to work was by creating a long string from my array of strings and then seperating them within the resource.

declare array like this :
[string[]]$product="ddd","dq","dqq"

Related

how to use json_extract_path_text?

I am facing an issue with JSON extract using JSON_EXTRACT_PATH_TEXT in redshift
I have two separate JSON columns
One containing the modems the customer is using and the other one containing the recharge details
{"Mnfcr": "Technicolor","Model_Name":"Technicolor ABC1243","Smart_Modem":"Y"}
For the above, I have no issue extracting the Model_name using JSON_EXTRACT_PATH_TEXT(COLUMN_NAME, 'Model_Name') as model_name
[{"Date":"2021-12-24 21:42:01","Amt":50.00}]
This one is causing me trouble. I used the same method above and it did not work. it gave me the below error
ERROR: JSON parsing error Detail: ----------------------------------------------- error: JSON parsing error code: 8001 context: invalid json object [{"Date":"2021-07-03 17:12:16","Amt":50.00
Can I please get assistance on how to extract this using the json_extract_path_text?
One other method I have found and it worked was to use regexp_substring.
This second string is a json array (square braces), not an object (curly brackets). The array contains a single element which is an object. So you need to extract the object from the array before using JSON_EXTRACT_PATH_TEXT().
The junction for this is JSON_EXTRACT_ARRAY_ELEMENT_TEXT().
Putting this all together we get:
JSON_EXTRACT_PATH_TEXT(
JSON_EXTRACT_ARRAY_ELEMENT_TEXT( <column>, 0)
, 'Amt')
you can use json_extract_path_text like below example
json_extract_path_text(json_columnName, json_keyName) = compareValue
for more you can refer this article
https://docs.aws.amazon.com/redshift/latest/dg/JSON_EXTRACT_PATH_TEXT.html

Datafactory : write get medata activity structure output to datalake

I am trying to write Generate Metadata to a file in datalake using copy file activity. But getting datatype issue when mapping structure filed to output schema
activity('Generate Metadata').output.structure
error:
Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Failed to convert the value in 'value' property to 'System.String' type. Please make sure the payload structure and value are correct.,Source=Microsoft.DataTransfer.DataContracts,''Type=System.InvalidCastException,Message=Object must implement IConvertible.,Source=mscorlib
As the error shows, it needs String type. So you should cast your activity('Generate Metadata').output.structure to String. Use this expression to have a try: #string(activity('Generate Metadata').output.structure).

How do I assign array of Objects as value to an Attribute in Apache NiFi

In Apache NiFi, My Mongo DB is returning Array of Objects as shown below
[
{ fname:john,
city:Nyc
},
{ lname:doe,
city:Nj
}
]
I am trying to assign the entire array of Objects to an Attrbiute using EvaluateJsonPath Processor,
my EvaluateJsonPath configuration is as shown below,but I am getting "EvaluateJsonPath unable to return a scalar" error.
I tried $.* in fullname value, tried changing return type to Scalar and auto detect. still I am getting the same error.
How do I assign the entire array of objects to an attribute in Apache NiFi
In case,if any one is interested
Changing Return type to Json and Fullname value to $.* resolved the issue.

Data factory lookup (dot) in the item() name

I am having lookup wherein salesforce query is there. I am using elements (item()) in subsequent activities. Till now i had item().name or item().email but now i have item().NVMStatsSF__Related_Lead__r.FirstName which has (dot) in the field name.
How should i parse it through body tag so that it reads it correctly?
So I have the following data in item()
{
"NVMStatsSF__Related_Lead__c": "00QE000egrtgrAK",
"NVMStatsSF__Agent__r.Name": "ABC",
"NVMStatsSF__Related_Lead__r.Email": "geggegg#gmail.com",
"NVMStatsSF__Related_Lead__r.FirstName": "ABC",
"NVMStatsSF__Related_Lead__r.OwnerId": "0025434535IIAW"
}
now when i use item().NVMStatsSF__Agent__r.Name it will not parse because of (dot) after NVMStatsSF__Agent__r. And it is giving me the following error.
'item().NVMStatsSF__Related_Lead__r.Email' cannot be evaluated because property 'NVMStatsSF__Related_Lead__r' doesn't exist, available properties are 'NVMStatsSF__Related_Lead__c, NVMStatsSF__Agent__r.Name, NVMStatsSF__Related_Lead__r.Email, NVMStatsSF__Related_Lead__r.FirstName, NVMStatsSF__Related_Lead__r.OwnerId'.",
"failureType": "UserError",
"target": "WebActivityToAddPerson"
this is because ADF uses '.' for object reading.
Could you find a way to rename the field name which contains '.'?
Seems like you need a built-in function to get the value of an object according to the key. Like getValue(item(), 'key.nestkey'). But unfortunately, seems there isn't such a function. You may need handle your key first.
Finally, it worked. I was being silly.
Instead of taking the value from the child table with the help of (dot) operator I just used subquery. Silly see.
And it worked.

Sharepoint REST Field Property does not exist

I am using Postman for Chrome to test some simply stuff with Sharepoints REST Api.
Well - I get an error right in the beginning while trying to retrieve certain Fields from a List - here are some pictures:
SharePoint List:
Calling for CPU
Calling for RAM - which fails:
(EXmsg: Field Property 'RAM' does not exist)
Anyone has a clue? I do not understand this at all.
Thanks in Advance!
P.s.
When calling:
/_api/web/lists/getbytitle('Anwendungen')/items
RAM will be displayed as a property of "zzfu" - dafuq?
This error occurs since $select query option accepts field internal name but not display name.
Having said that, you might need first to determine field internal name, for example:
/_api/web/lists/GetByTitle('Anwendungen')/fields?$select=InternalName&$filter=Title eq 'RAM'
Once the field internal is determined, you could query field value like this:
/_api/web/lists/GetByTitle('Anwendungen')/items?$select=<RAM internal name>
where <RAM internal name> is RAM field internal name.