Powershell, web services and object types


I’m new to using web services under powershell, so maybe I have a basic misunderstanding about something. I’m working with Microsoft’s Reporting Services. Here is a repro script.

If I run that, I get something that looks more or less like this:

So, my question is: Why does DataSource have System.Object as a BaseType when DataSourceReference clearly has a object type that is based on the web object? They were both created from the ReportingWebService namespace, weren’t they?

My root problem is that I need to hand an array of DataSources back to SetItemDataSources, and SetItemDataSources chokes on an array of System.Objects, and I don’t seem to be able to cast it to what I want.


All this means is that the “DataSource” class inherits directly from System.Object. Whereas “DataSourceReference” inherits from “DataSourceDefinitionOrReference”, then maybe something else, then System.Object.

However, I do not think that is your problem. Your problem is probably PowerShell’s automatic splitting and recombining of collections as generic collections of System.Object. You can control this by setting a static type on the collection like so (I’m guessing on this API you are using since I haven’t used it myself):


Powershell, web services and object types by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply