PowerTip: Use Set-Variable to Create a ReadOnly PowerShell Variable

Doctor Scripto

Summary: Use the Set-Variable cmdlet to create a ReadOnly Windows PowerShell variable.

Hey, Scripting Guy! Question How can I create a ReadOnly variable in Windows PowerShell?

Hey, Scripting Guy! Answer Use the Set-Variable cmdlet to create a ReadOnly variable, and specify ReadOnly for the Option parameter, and you can specify a description for the variable:

Set-Variable -Name myvariable -Value “value” -Description “mred variable” -Option readonly



Discussion is closed.

Feedback usabilla icon