Amm*_*mar 15 variables powershell
我想在脚本开头删除所有用户创建的变量.
目前我正在做Remove-Variable -Name *但它也试图删除所有系统变量,导致大量错误消息.
还有其他方法吗?
Joe*_*oey 27
由于所有系统变量都是只读或常量,因此您可以将错误静音:
Remove-Variable * -ErrorAction SilentlyContinue
Run Code Online (Sandbox Code Playgroud)
但诚然,你应该排除一些:
Get-Variable -Exclude PWD,*Preference | Remove-Variable -EA 0
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
73515 次 |
| 最近记录: |