如何清除Powershell中的变量内容

Joh*_*han 4 powershell

我昨天才开始学习有关powershell的知识。非常新的功能。我已经创建了很多用于测试目的的变量。以下是我对变量的提问

  1. 如何列出我之前创建的所有变量?
  2. 然后如何清除变量的所有内容?
  3. 如何删除/删除变量?

Tra*_*z13 7

  1. 如何列出以前创建的所有变量?

    • 这将获取所有变量,而不仅仅是您创建的变量,您需要过滤到您关注的变量: Get-Variable -name <name without $>
  2. 然后如何清除变量的所有内容?

    • Clear-Variable -name <name without $>
  3. 如何删除/删除变量?
    • Remove-Variable -name <name without $>

  • 键入不带 $ 的变量名称 (2认同)
  • 如何从函数内部清除全局变量? (2认同)