Behind the PowerShell Pipeline logo

Behind the PowerShell Pipeline

Subscribe
Archives
March 9, 2023

PowerShell Construction Area

In the last article, I started a series focused on scripting with PowerShell classes. The eventual goal is to separate the object definition from the code that creates an object instance. A defined object class lets you define formatting rules and create custom type extensions.

Defining a class in a PowerShell script file is as easy as this:

class SpaceShip {
    [String]$Name
    [String]$Captain
    [Int32]$CrewSize
    [DateTime]$Manufactured
    [String]$Class
    [String]$RegistrationNumber
}

You can create a new instance of the object with this intrinsic New() method.

Want to read the full issue?
GitHub Bluesky LinkedIn Mastodon https://jdhitsoluti…
Powered by Buttondown, the easiest way to start and grow your newsletter.