I am currently working through some webservice calls wrote in C# .net and converting these to PowerShell. This has been going ok until I got to the following:
You’re creating an array with two elements. That’s shorthand for calling the array constructor with an argument of two, which looks like this in PowerShell:
$test.systemFields = New-Object -TypeName systemFieldsType[] -ArgumentList 2
# Or as I usually write it, out of habit:
$test.systemFields = New-Object systemFieldsType[](2)
I know that second syntax is sort of me wishing that New-Object was just like the new statement in C#, but I can’t break the habit. That’s what New should look like.