Windows Powershell v1.0 Problem
First of all ... I just created by first Cmdlet last week! The bad part? It doesn't work. Well, it doesn't work
as expected, I should say. Let me give you a brief overview of the issue I ran into.
I recently decided to go ahead and start developing a set of cmdlets to manage a
Microsoft Systems Management 2003 Server. Since we use SMS 2003 at my company, I figured it would be cool to expose the functionality through Powershell in case we wanted to script/automate SMS "stuff." I know that there are some existing
SMS cmdlets out there, however these seem to target SMS clients rather than servers.
I started out by writing a cmdlet called
Get-SMSCollections that did simply that ... it retrieved a list of SMS collections from an SMS server that is specified as a parameter. I ran into a bit of a bind, however, when trying to run this cmdlet. I'm currently getting an error message stating
: "
format-default : Value was either too large or too small for an Int32." Now, I assume, naturally, that this message is coming from the format-default cmdlet, and some value I'm passing to it from my cmdlet is larger or smaller than an Int32 can handle. I'm really at odds as to what exactly this value is, however.
Please note that the yellow warning text is coming from an Exception handler in my cmdlet and is not actually reflective of the real problem (it's just some static text I wrote in, in case anything fails). Now, since the error message is coming from
format-default, I figured that I'd try something else to see what happens:
Get-SMSCollections | Select-Object name,collectionID.
This command actually works, and outputs the names and collection IDs of all my SMS collections! Now, that tells me that something, somewhere, some sort of data is messing up the
format-default cmdlet.
I wish I knew what it was ...
The really weird thing though, is that I can run a
Select-Object on any of the properties individually, and successfully retrieve them! So, what sort of data is Powershell trying to retrieve that it's unable to display???