properties - Set service contract object property programmatically using Powershell -
properties - Set service contract object property programmatically using Powershell -
i have service i'm consuming using new-webserviceproxy cmdlet. service contract contains custom serializable objects.
an illustration of 1 of these objects may defined as:
public class person { public string firstname { get; set; } public string lastname { get; set; } } or, in powershell using get-member:
name membertype definition ---- ---------- ---------- firstname property string firstname {get;set;} lastname property string lastname {get;set;} note: not command web service, third-party closed-source service. consuming it.
i want able modify property values using powershell. if have person instance called $person, , seek this:
$person | set-itemproperty -name firstname -value john the next error occurs:
the input object cannot bound parameters command either because command not take pipeline input or input , properties not match of parameters take pipeline input.
whereas if this:
$person.firstname = 'john' it works fine.
how can programmatically set property values on service object?
you can access , set object's properties dynamically @ runtime so:
$propertyname = 'firstname' $person.$propertyname = 'john' powershell evaluate $propertyname firstname , set firstname property though defined @ runtime.
powershell properties
Comments
Post a Comment