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:
test.systemFields = new systemFieldsType
int j = 0;
In PowerShell I am trying:
$test.systemFields = New-Object systemFieldsType
I can see systemFieldsType as an option but it doesn't like me adding .
Any ideas how I deal with this in PowerShell?
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. 😛
Thanks for the reply.
When I run :
I get the 'name' and 'value' headers. However, when I run:
I don't get the headers and cannot set the following:
int j = 0;
You must be logged in to reply to this topic.