as the title says how can I convert a string collection into a string array in powershell don't know where to start with this as I am new to powershell. Would it be anything like String[])$viewFields.toArray(new String[0])
2 Answers
To create an array out of anything surround with @(...). To create an array of a specific type, System.Array has some factory methods and use [type] to get a Type object. Thus
$theArray = @($viewFields.toArray([array]::CreateInstance([string], 0)))