Reputation: 595
I have this object in Powershell which I obtained from a query against the SSRS Web Service:
$ds|gm
TypeName: Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3tServer_ReportService2010_asmx.DataSource
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Item Property Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3tServer_ReportService2010_asmx.DataSourceDe...
Name Property string Name {get;set;}
If I list the $ds object:
$ds|fl
Name : AHPUsersData
Item : Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3tServer_ReportService2010_asmx.DataSourceReference
What I need is the value of "Item" which actually appears to be the type of an object stored in "Item". I've try assigning $ds.Item to a new object but it just turns into a Powershell custom object and all that info goes away. I've tried various combinations of GetType with no success. Ultimately what I need is the last part of:
Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3tServer_ReportService2010_asmx.DataSourceReference
Which is the "DataSourceReference" string. This part can have two values, "DataSourceReference" or "DataSourceDefinition" and I need to test that to determine the code to execute next.
Relative newbie to Powershell and this one is a bit obtuse for me. Any help is greatly appreciated.
Upvotes: 1
Views: 690
Reputation: 58931
Just expand the Item
with Select-Object
:
$ds | select -expand Item
Upvotes: 1
Reputation: 14695
I don't know exactly what you need, but you could also create your own custom PSCustomObject
like this:
[PSCustomObject]@{
Name = $ds.Name
DataSourceReference = $ds.Item.DataSourceReference
SomethingElse = $ds.Item | Select-Object -ExpandProperty DataSourceReference
}
At first you select the PropertyName
and then the PropertyValue
, which can be anything you like. Hopefully this helps you out.
Upvotes: 0