How to do it...

Install and start PowerShell Core and execute the following steps:

  1. Try to execute the following code block:
$true = $false
$pid = 0
$Error = "I don't make mistakes!"
  1. Execute the next cmdlet to see why Step 1 didn't work as intended:
Get-Variable | Where-Object -Property Options -like *Constant*
  1. You can create your own read-only and constant variables using variable cmdlets:
# Creating read-only and constants requires the variable cmdlets
$logPath = 'D:\Logs'
Set-Variable -Name logPath -Option ReadOnly
  1. Modifying read-only variables is still possible with the -Force parameter:
Set-Variable -Name logPath -Value '/var/log' -Force
  1. The Option parameter is useful for other purposes as well, such as creating private and global variables:
Get-Help -Name New-Variable -Parameter Option