May 13th, 2013

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

Doctor Scripto
Scripter

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

 

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.