Skip to main content

Posts

Showing posts from February, 2018

Overwriting a PowerShell Constant

I have always said that one of the greatest benefit to teaching PowerShell (and Windows) is that different people bring different ideas to the table.  Things get fun for me when someone looks at what we are doing from a different angle and asked an interesting question. This week’s class in Fort Wayne produced one of those questions.  We were looking at some of the options that are available to use with creating variables with the New-Variable cmdlet.  In particular, we were looking at constants.  Let’s build one. PS C:\> New-Variable -Name Test1 -Value ([Bool]$True) -Option Constant Now let’s take a look at the variable object. Name        : Test1 Description : Value       : True Visibility  : Public Module      : ModuleName  : Options     : Constant Attributes  : {} We can see from the Options property that we have created a constant.  We are going to attempt to change that value of this constant to FALSE. PS C:\> Set-Variable -Name Test