Life of a techno-guru
Monday, December 24, 2007
  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???
 
Comments:
It seems that one of your properties is not in the 'range' of Int32.

PS:11 >[int32]$int=1111111111111111
Cannot convert value "1111111111111111" to type "System.Int32". Error: "Value was either too large or too small for an Int32."
At line:1 char:12
+ [int32]$int <<<< =1111111111111111

This seems to work, consider changing the type to Int64.
PS > [int64]$int=1111111111111111


Anyway, you can post any problem to the PowerShell news group, there's nothing they can't fix :-)

-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
 
Post a Comment



<< Home
My life of learning various things about technology including network administration, development, and 3D design

Name:
Location: Chicago, Illinois, United States
ARCHIVES
January 2006 / February 2006 / March 2006 / May 2006 / June 2006 / July 2006 / August 2006 / September 2006 / October 2006 / November 2006 / December 2006 / January 2007 / February 2007 / March 2007 / April 2007 / May 2007 / June 2007 / August 2007 / December 2007 / January 2008 / March 2008 / April 2008 / June 2008 / July 2008 / September 2008 / December 2008 / January 2009 / February 2009 / March 2009 / May 2009 /


Powered by Blogger