powershell - Remove all variables

后端 未结 8 768
礼貌的吻别
礼貌的吻别 2020-12-31 05:05

I want to remove all user-created variables at the start of a script.

Currently I am doing Remove-Variable -Name * but it tries to dele

8条回答
  •  滥情空心
    2020-12-31 05:39

    I suppose you could make a list of all the variables you don't want to delete.

    $DontDelete = '$','?','^','args',...,'WhatIfPreference'
    

    Then delete the variables that are not on the Don't Delete list.

提交回复
热议问题