Plane flying across blue sky with cloud trail

Q. Can I declare constants in Windows PowerShell?

A. To declare constants, you use the New-Variable cmdlet. It includes a switch that lets you define the new variable as a constant, meaning its value can't be changed. (I'll make you run

Help New-Variable

to see which one.) Note that all variables are discarded when their scope is destroyed (such as when a script finishes running).

Do you have a Windows PowerShell question? Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish