powershell - 添加“获取模块 | 移除模块;Clear-Host' 到包含的 PowerShell 代码
问题描述
Stack Overflow 上的某个人分享了以下 PowerShell 代码。我的代码在我修改的脚本中工作。我想Get-Module | Remove-Module; Clear-Host
向它添加功能。
并且在运行脚本后添加这些实际上会有所帮助还是会产生任何不良影响?
我是 Stack Overflow 上的新手,没有评论代码所在线程的声誉。所以我提出了一个新问题。
### Start of script (store list of existing variable names)
$ExistingVariables = Get-Variable | Select-Object -ExpandProperty Name
### End of script (remove new variables)
$NewVariables = Get-Variable | Select-Object -ExpandProperty Name | Where-Object {$ExistingVariables -notcontains $_ -and $_ -ne "ExistingVariables"}
if ($NewVariables)
{
Write-Host "Removing the following variables:`n`n$NewVariables"
Remove-Variable $NewVariables
}
else
{
Write-Host "No new variables to remove!"
}
解决方案
推荐阅读
- javascript - Zlib 无法解压 utf8 编码的字符串
- android - 通过相机捕获图像并将其保存到图库中
- python - Pyautogui 用于不同的分辨率
- highcharts - 在许多 highcharts 图表之间同步最大最小值(实时)
- math - 查找最近的线及其 x,y 位置
- javascript - Webpack 4:如何使用参数调用全局函数?
- opengl - openGL gl_Polygon 混合颜色问题
- python - 我的 LSTM 代码给出了平面预测,不知道出了什么问题..任何人都可以帮忙看看吗?
- c# - 修复背景粉碎 C# winforms
- python - 如何从电子邮件 Python 中删除多余的语法?