I would like to declare some integer constants in PowerShell.
Is there any good way to do that?
Use
Set-Variable test -Option Constant -Value 100
or
Set-Variable test -Option ReadOnly -Value 100
The difference between "Constant" and "ReadOnly" is that a read-only variable can be removed (and then re-created) via
Remove-Variable test -Force
whereas a constant variable can't be removed (even with -Force).
See this TechNet article for more details.