删除所有变量后,(愚蠢地)Powershell ISE无法启动

时间:2011-04-14 17:03:13

标签: powershell powershell-ise

我渴望找出哪些变量是受保护的或常量,我决定只看看哪些变量可以被删除 - 假设上面提到的那些将被遗漏。我没有意识到的是,这些变量的删除不仅限于ISE本届会议的范围 - 而且不仅仅是Powershell全球 - 而是全球系统。我希望有人能帮助我让ISE再次工作。

我的愚蠢:

Remove-Variable *  

...导致报告了一堆错误,之后我执行dir variable:时只剩下少量(10-15)。认为这没什么大不了的,ISE的重新启动会使我恢复正常,我关闭它 - 它不会启动。

其他症状

我发现我已经丢失了环境变量%windir%之类的内容 - 这是最有趣的转折,阻止您打开高级系统设置(无法找到%windir%\system32\systempropertiesadvanced.exe )设置你的ENV备份...(是的,我可以直接运行)

更新:我发现了一个额外的效果/症状:Windows报告说在自动更新无法正常工作后我可能没有正版Windows。我没有意识到像一些ENV变种那样简单的东西会消灭它。 HRM。

那么 - 有谁知道如何恢复或重新创建成功运行ISE所需的环境?

(是的,我尝试删除并重新添加功能,并重新启动。)

2 个答案:

答案 0 :(得分:2)

我刚刚在ISE中删除了 - 变量*,没有任何事情发生。我仍然可以打开ISE并像往常一样工作。我还做了一个-WhatIf来看看真正被删除的内容。

PS H:\> Remove-Variable * -WhatIf
What if: Performing operation "Remove Variable" on Target "Name: null".
What if: Performing operation "Remove Variable" on Target "Name: false".
What if: Performing operation "Remove Variable" on Target "Name: true".
What if: Performing operation "Remove Variable" on Target "Name: MaximumErrorCount".
What if: Performing operation "Remove Variable" on Target "Name: MaximumVariableCount".
What if: Performing operation "Remove Variable" on Target "Name: MaximumFunctionCount".
What if: Performing operation "Remove Variable" on Target "Name: MaximumAliasCount".
What if: Performing operation "Remove Variable" on Target "Name: MaximumDriveCount".
What if: Performing operation "Remove Variable" on Target "Name: Error".
What if: Performing operation "Remove Variable" on Target "Name: PWD".
What if: Performing operation "Remove Variable" on Target "Name: ?".
What if: Performing operation "Remove Variable" on Target "Name: MaximumHistoryCount".
What if: Performing operation "Remove Variable" on Target "Name: Host".
What if: Performing operation "Remove Variable" on Target "Name: HOME".
What if: Performing operation "Remove Variable" on Target "Name: ExecutionContext".
What if: Performing operation "Remove Variable" on Target "Name: PSVersionTable".
What if: Performing operation "Remove Variable" on Target "Name: PID".
What if: Performing operation "Remove Variable" on Target "Name: PSCulture".
What if: Performing operation "Remove Variable" on Target "Name: PSUICulture".
What if: Performing operation "Remove Variable" on Target "Name: ShellId".
What if: Performing operation "Remove Variable" on Target "Name: PSHOME".
What if: Performing operation "Remove Variable" on Target "Name: ConsoleFileName".
What if: Performing operation "Remove Variable" on Target "Name: $".
What if: Performing operation "Remove Variable" on Target "Name: ^".
What if: Performing operation "Remove Variable" on Target "Name: StackTrace".
What if: Performing operation "Remove Variable" on Target "Name: OutputEncoding".
What if: Performing operation "Remove Variable" on Target "Name: ConfirmPreference".
What if: Performing operation "Remove Variable" on Target "Name: DebugPreference".
What if: Performing operation "Remove Variable" on Target "Name: ErrorActionPreference".
What if: Performing operation "Remove Variable" on Target "Name: ProgressPreference".
What if: Performing operation "Remove Variable" on Target "Name: VerbosePreference".
What if: Performing operation "Remove Variable" on Target "Name: WarningPreference".
What if: Performing operation "Remove Variable" on Target "Name: ErrorView".
What if: Performing operation "Remove Variable" on Target "Name: NestedPromptLevel".
What if: Performing operation "Remove Variable" on Target "Name: ReportErrorShowExceptionClass".
What if: Performing operation "Remove Variable" on Target "Name: ReportErrorShowInnerException".
What if: Performing operation "Remove Variable" on Target "Name: ReportErrorShowSource".
What if: Performing operation "Remove Variable" on Target "Name: ReportErrorShowStackTrace".
What if: Performing operation "Remove Variable" on Target "Name: WhatIfPreference".
What if: Performing operation "Remove Variable" on Target "Name: FormatEnumerationLimit".
What if: Performing operation "Remove Variable" on Target "Name: PSEmailServer".
What if: Performing operation "Remove Variable" on Target "Name: PSSessionOption".
What if: Performing operation "Remove Variable" on Target "Name: PSSessionConfigurationName".
What if: Performing operation "Remove Variable" on Target "Name: PSSessionApplicationName".
What if: Performing operation "Remove Variable" on Target "Name: psUnsupportedConsoleApplications".
What if: Performing operation "Remove Variable" on Target "Name: PSBoundParameters".
What if: Performing operation "Remove Variable" on Target "Name: args".
What if: Performing operation "Remove Variable" on Target "Name: input".
What if: Performing operation "Remove Variable" on Target "Name: MyInvocation".
What if: Performing operation "Remove Variable" on Target "Name: _".
What if: Performing operation "Remove Variable" on Target "Name: psLocalHelp".
What if: Performing operation "Remove Variable" on Target "Name: psOnlineHelp".
What if: Performing operation "Remove Variable" on Target "Name: psISE".
What if: Performing operation "Remove Variable" on Target "Name: profile".

注意到在列表中真的很难过。顺便说一句,这些只是ISE运行空间中的变量。我不确定如何删除这些变量会阻止ISE完全运行。

答案 1 :(得分:0)

感谢大家的帮助 - 这就是我所做的,虽然我不确定是否让我100%回到任何地方,但我允许我使用ISE,Hyper-V管理器并再次验证为真品。

我转到另一个Server 2008 R2框,比较密钥并手动编辑注册表并将这些值添加回损坏的计算机:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
  Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;
  PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
  PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
  TEMP=C:\Windows\TEMP
  TMP=C:\Windows\TEMP
  windir=C:\Windows

我倾向于提升ISE的管理员权限,因为它影响了会议的主要原因。