When I convert the variable value which is in string to an array format, it converted data type to an array but the result is not an array.
Example:
cls
#Actual String value concatenated with dot (.)
$EmpInfo="Name.Address.Pincode.Phone"
Write-Host $EmpInfo
#Change string value to array format
$EmpInfoArray= '"'+$EmpInfo.Replace('.',""",""")+'"'
Write-Host $EmpInfoArray
$EmpInfoArray.gettype()
#Convert BaseType value from 'system.object' to 'system.array'
[Array]$ConvertedArray = $EmpInfoArray
$ConvertedArray.GetType()
Write-Host $ConvertedArray.Count
Write-Host $ConvertedArray[0]
Result:
1
"Name","Address","Pincode","Phone"
It is not resulting the value as an array. If it is an array then the result would be array count 4 and first array value 'Name'
Do we have any workaround to result the converted user specified string value to an array.