3

In my eagerness to find out what variables were protected or constants, I decided to just see what ones could be removed - assuming those mentioned above would be left alone. What I didn't realize is the removal of those variables would not be limited to the scope of this session of the ISE - but was not only PowerShell global - but system global. I'm hoping that someone can help me get the ISE working again.

My foolishness:

Remove-Variable *  

...resulted in a bunch of errors reported and only a handful (10-15) remaining when I executed dir variable: afterward. Thinking it was no big deal and that a restart of the ISE would restore me to normality, I closed it -- and I cannot start it anymore.

Additional Symptoms

I've since found that I've lost things like environment variables %windir% are gone - which in a most interesting twist, prevents you from opening your Advanced system settings (can't find %windir%\system32\systempropertiesadvanced.exe) to set your ENV back up... (Yes, I can run it directly)

Update: I found an additional effect/symptom: Windows reported that I may not have a genuine version of Windows after the auto-update was not able to work correctly. I hadn't realized that something as simple as some ENV vars being gone would kill that. Hrm.

So - anyone knows how to restore or re-create the environment needed to successfully run the ISE?

(And yes, I've tried removing and re-adding the Feature, combined with reboots.)

2
  • You must have done something else. Removing the variables will only affect your current PowerShell session unless you have a very nonstandard setup there. Commented Apr 15, 2011 at 9:55
  • I expected the exact same thing - only a session change, yet after running the command, HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment was reduced to just a few values. I now note that the ISE defaults to running as Administrator on this machine - whereas it's not privileged on any of my others. Curious - I didn't elevate it manually. Though I'm guessing that may be the difference and why it wasn't limited in scope. Thanks for the help! Commented Apr 15, 2011 at 17:19

2 Answers 2

2

I did remove-Variable * in ISE just now and nothing happend. I can still open ISE and work as usual. I also did a -WhatIf to see what really gets removed.

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".

Noting really scray in that list. BTW, these are just variables in the ISE runspace. I am not sure how removing these variables would prevent ISE from functioning altogether.

Sign up to request clarification or add additional context in comments.

1 Comment

As I commented above, I'm guessing that the elevated Administrator privilege of the ISE had something to do with it - because I thought the same as you! Thanks for the help!
0

Thanks all for the assist - here's what I did, which while I'm not sure got me back 100% everywhere, has allowed me to use the ISE, Hyper-V Manager and validate as genuine again.

I went to another Server 2008 R2 box, compared the key and manually edited the registry and added these values back to the broken machine:

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

I'm leaning towards the elevated Administrator privilege of the ISE as the underlying reason it affected more than the session.

1 Comment

I'm noticing that on Win10 systems, the "C:\Windows" portions of this reference %systemroot% instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.