Wednesday, 20 August 2008


Illustrates Int16 data type
This script creates,displays and formats an Int16.
File Name : Get-Int16.ps1
Author : Thomas Lee -
Requires : PowerShell V2
PSH [C:\foo]: .\get-int16.ps1
The value of this int16 is: 4142
The value of this int16 is: 4,142

Min value of an Int16 is: -32,768
Max value of an Int16 is: 32,767

# Start of Script

# Create the int16

[system.int16] $i = 0

# set and display a value:
'The value of this int16 is: {0}' -f $i

# and nicely formatted
'The value of this int16 is: {0}' -f $i.tostring('0,000')

# Max/Min value
'Min value of an Int16 is: {0}' -f [System.Int16]::minvalue.tostring('0,000')
'Max value of an Int16 is: {0}' -f [System.Int16]::maxvalue.tostring('0,000')
# End of script

1 comment:

halr9000 said...

If I may make a suggestion--I'm not sure that you are providing as much value as you could when you post these scripts without any background for them or explanation of how they work. If all you want to do is "dump" scripts out there, we (I'm speaking on behalf of would greatly appreciate seeing those entered into That way they will be in a searchable respository that already has integration with powershell (see, and PowerGUI (see

On the other hand, if you *really* want to add value, I'd recommend slowing down on the pace. For each article you may want to consider writing the background for why you wrote it and then explain to new users how it works. Or something along those lines.

Just trying to spread knowledge as far and wide as I can! (with my $0.02 worth)

Community Director,