Is there any way to pass an array to a PowerShell script?
Able to pass a variable except array.But when trying to pass an array using same method getting an error "Cannot convert progam parameter at position 0 to string"
What I have been doing since upgrading to CAPA 4.3.2 is using the REST API to read the DataSet variables from the job and converting it into a PowerShell Object.
This allows me to pass all kinds of complex variable types (except passwords) to PowerShell and not having to worry about fancy parsing.
I have attached a sample version of the PowerShell code that I use, the only parameters you need to pass to the script are as follows:
[string]$CAPA_Username Username of account that has access to the process [string]$CAPA_Password Password of account that has access to the process [string]$CAPA_ServerName Base URL of the CAPA Server (i.e. capa-automation-dev.***.***:8443)[string]$CAPA_InstanceID Instance ID of the job that you want to retrieve the data for
The script will convert the results of the REST API call to an object, when you want to retrieve a variable from the object you just call the function and pass the CAPA variable name.
i.e. ReturnDataSetVariable "Environment.SCOM.Preproduction"
In the case of an array (because the index is appended to the name), you can pass the name with a * at the end, and it will return a list of the values
Key Value --- ----- Environment.SCOM.Preproduction server-1.***.***Environment.SCOM.Preproduction server-2.***.***Environment.SCOM.Preproduction server-3.***.***
Hope this helps!