header image

PowerShell classes – – static classes

Posted by: | November 9, 2014 Comments Off on PowerShell classes – – static classes |

A static class is one that you don’t need to create  an instance of the object to use – the [math] class provides many examples e.g.

£> [math]::pi


You can create a class with static methods using PowerShell classes:

class stest {

static [int] doubleup ([int] $in){

return $in * 2



Its used like this:

£> [stest]::doubleup(2)


Where could you use this – possibly to resolve look up values for instance when decoding WMI integer values or if you have a series of calculations you’ll be using in several select statements

under: PowerShell v5

Comments are closed.