Press "Enter" to skip to content

Static Properties and Methods in Powershell Classes

Robert Cain continues a series on Powershell classes:

Over the last few articles we’ve been covering PowerShell objects. The first article in the series, Fun With PowerShell Classes – The Basics, covered the basics of using of the PowerShell class construct introduced in PowerShell version 5.

If you’ve not read it I’d suggest you do so now as we’ll be building on it in this article, as well as in the next two, as we explore the advanced capabilities of PowerShell classes. In this post we’ll cover the concept of static properties and methods.

Read on to see what’s special about static methods and properties. My well-founded biases: static methods are fine, great even (but remember that I’m very biased toward functional programming and away from object-oriented programming). Static properties are usually a bad idea, especially in multi-user applications.