beavel.com - Beavel's blog | The Thoughts of One Technologist

Description: The Thoughts of One Technologist

Example domain paragraphs

I have had a few modules that I have developed where I desired to use the Singleton pattern as I didn’t want multiple instances of a particular object running about across scripts. Building full fledge objects in PowerShell is a bit verbose and not the most straightforward process. I’m also not certain you can properly build an honest Singleton class natively in PowerShell. An alternative to building objects natively in PowerShell is to use C# in line and compile the class with Add-Type. Although that is an

# Instatiate Log # $Log = Get-LogInstance "Log Description" This remove the need for checking if the variable had been created in each script, and I could call scripts in any order knowing I would get a valid and the correct instance of the object I wanted.

Tags: patterns , powershell , singleton