【问题标题】:How to clear variable content in powershell如何清除powershell中的变量内容
【发布时间】:2016-05-19 03:23:08
【问题描述】:

我昨天刚开始学习 powershell。非常新的powershell。我为测试目的创建了很多变量。以下是我关于变量的问题

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

【问题讨论】:

    标签: powershell


    【解决方案1】:
    1. 如何列出我之前创建的所有变量?

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

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

    【讨论】:

    • 谢谢特拉维斯。真正有用的信息。但是,当我使用 Get-Variable $myvariable 时,它​​会显示错误“Get-Variable : Cannot find a variable with name 'variable name'”。使用 Clear-Variable 时出现相同的错误消息
    • 键入不带 $ 的变量名
    • 对此问题的答案进行了澄清
    • 如何从函数内部清除全局变量?
    猜你喜欢
    • 2023-03-19
    • 2022-11-10
    • 1970-01-01
    • 1970-01-01
    • 2019-05-12
    • 2010-12-19
    • 2019-11-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多