Archive for April, 2009

How to uninstall Powershell v1.0 from Windows Server 2003 R2

Monday, April 27th, 2009

If you’re lucky, you can uninstall Powershell simply by finding the Windows update in ARP that has the signature blue icon.  When I was rolling out Powershell CTP3 (now deeply integrated into our build & deploy scripts), this worked on the majority of our machines.  All except the TFS server, as luck would have it.  Figures!

According to KB926140, this will fail if you installed Powershell before you installed SP2 (or upgraded to R2) because the latter update includes the former.  MSI patching is fun like that.  So if you want v2.0 goodness, it’s time to do some surgery.

WARNING: this is completely unsupported by Microsoft.  It happened to work for me.  YMMV.

First you need to dig up a copy of PSCustomSetup.exe.  If you have a machine that already has PS v1.0 on it, you’ll find this tool in %windir%\$NtUninstallKB926139$.  (Note: the KB number may be 928439 on Vista, but I don’t have a Vista machine to say for sure.  Use your “gci -filter” skillz.)  Or you can dig it out of the v1.0 install package.  You might also try to grab a copy of spuninst.inf that’s appropriate for your OS, just to sanity check you aren’t missing anything, though we will be hacking our own…

Basically, we need to manually replay the steps that the uninstaller would have taken.  Ordinarily, the .inf file spells this out in a vaguely human-readable format.  Thanks to the efforts of some folks around the net[1][2][3], I was able to come up with a comprehensive list.  Technically it can vary from OS to OS, or even machine to machine, but you wouldn’t be here unless you had the 2003 R2 issue in particular – XP and Vista aren’t affected since PS is not part of their service packs.  Plus, it’s fairly easy to abstract out the machine-specific paths with an environment variable here & there.  Thus, my instructions:

1) Copy the PSCustomSetup.exe you found to a temporary directory on the affected machine.

2) Copy/paste this first script block into a file named uninstall.cmd and save it into the temporary directory.

pushd %windir%\Microsoft.NET\Framework\v2.0.50727 ngen.exe uninstall "System.Management.Automation,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil" /silent /nologo /NoDependencies ngen.exe uninstall "Microsoft.PowerShell.ConsoleHost,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil" /silent /nologo /NoDependencies ngen.exe uninstall "Microsoft.PowerShell.Commands.Management,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil" /silent /nologo /NoDependencies ngen.exe uninstall "Microsoft.PowerShell.Commands.Utility,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil" /silent /nologo /NoDependencies ngen.exe uninstall "Microsoft.PowerShell.Security,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil" /silent /nologo /NoDependencies ngen.exe uninstall "System.Management.Automation.resources,Version=1.0.0.0,Culture=en,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil" /silent /nologo /NoDependencies ngen.exe uninstall "Microsoft.PowerShell.ConsoleHost.resources,Version=1.0.0.0,Culture=en,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil" /silent /nologo /NoDependencies ngen.exe uninstall "Microsoft.PowerShell.Commands.Management.resources,Version=1.0.0.0,Culture=en,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil" /silent /nologo /NoDependencies ngen.exe uninstall "Microsoft.PowerShell.Commands.Utility.resources,Version=1.0.0.0,Culture=en,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil" /silent /nologo /NoDependencies ngen.exe uninstall "Microsoft.PowerShell.Security.resources,Version=1.0.0.0,Culture=en,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil" /silent /nologo /NoDependencies popd PSCustomSetupUtil.exe /uninstall "System.Management.Automation,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil"" PSCustomSetupUtil.exe /uninstall "Microsoft.PowerShell.ConsoleHost,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil"" PSCustomSetupUtil.exe /uninstall "Microsoft.PowerShell.Commands.Management,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil"" PSCustomSetupUtil.exe /uninstall "Microsoft.PowerShell.Commands.Utility,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil"" PSCustomSetupUtil.exe /uninstall "Microsoft.PowerShell.Security,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil"" PSCustomSetupUtil.exe /uninstall "System.Management.Automation.resources,Version=1.0.0.0,Culture=en,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil"" PSCustomSetupUtil.exe /uninstall "Microsoft.PowerShell.ConsoleHost.resources,Version=1.0.0.0,Culture=en,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil"" PSCustomSetupUtil.exe /uninstall "Microsoft.PowerShell.Commands.Management.resources,Version=1.0.0.0,Culture=en,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil"" PSCustomSetupUtil.exe /uninstall "Microsoft.PowerShell.Commands.Utility.resources,Version=1.0.0.0,Culture=en,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil"" PSCustomSetupUtil.exe /uninstall "Microsoft.PowerShell.Security.resources,Version=1.0.0.0,Culture=en,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=msil"" PSCustomSetupUtil.exe /removeenvvariable PATH "C:\WINDOWS\system32\WindowsPowerShell\v1.0" PSCustomSetupUtil.exe /removeenvvariable PATHEXT ".PSC1" PSCustomSetupUtil.exe /wmsettingchange rd /s /q %windir%\$NtUninstallKB926139$ rd /s /q %windir%\system32\windowspowershell pushd %windir%\assembly\gac_msil rd /s /q System.Management.Automation rd /s /q Microsoft.PowerShell.ConsoleHost rd /s /q Microsoft.PowerShell.Commands.Management rd /s /q Microsoft.PowerShell.Commands.Utility rd /s /q Microsoft.PowerShell.Security rd /s /q System.Management.Automation.resources rd /s /q Microsoft.PowerShell.ConsoleHost.resources rd /s /q Microsoft.PowerShell.Commands.Management.resources rd /s /q Microsoft.PowerShell.Commands.Utility.resources rd /s /q Microsoft.PowerShell.Security.resources popd

3) Open a CMD window, navigate to the temporary directory, and run the script.  Watch for errors.  (Post to the comments…)  Make sure it’s a 64-bit CMD window if you’re on x64 Windows.

4) Copy this block of text to a file named uninstall.reg and save it to the temporary directory.  Run it and accept the “yes, I really want to do this” prompt.

Windows Registry Editor Version 5.00 [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell] [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\OID\EncodingType 0\CryptSIPDllCreateIndirectData\{603BCC1F-4B59-4E08-B724-D2C6297EF351}] [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\OID\EncodingType 0\CryptSIPDllGetSignedDataMsg\{603BCC1F-4B59-4E08-B724-D2C6297EF351}] [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\OID\EncodingType 0\CryptSIPDllIsMyFileType2\{603BCC1F-4B59-4E08-B724-D2C6297EF351}] [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\OID\EncodingType 0\CryptSIPDllPutSignedDataMsg\{603BCC1F-4B59-4E08-B724-D2C6297EF351}] [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\OID\EncodingType 0\CryptSIPDllRemoveSignedDataMsg\{603BCC1F-4B59-4E08-B724-D2C6297EF351}] [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\OID\EncodingType 0\CryptSIPDllVerifyIndirectData\{603BCC1F-4B59-4E08-B724-D2C6297EF351}] [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\KB926139] [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows Server 2003\SP2\KB926139] [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows PowerShell 1.0] [-HKEY_CLASSES_ROOT\.ps1] [-HKEY_CLASSES_ROOT\.ps1xml] [-HKEY_CLASSES_ROOT\.psc1] [-HKEY_CLASSES_ROOT\Microsoft.PowerShellConsole.1] [-HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1] [-HKEY_CLASSES_ROOT\Microsoft.PowerShellXmlData.1]

5) Install Powershell v2.0

6) Clean up the temp dir.

Success?  Hope so – if not, it’s probably time to nuke that install!  (or at minimum, restore from backup)  Good luck everyone. 

Note: these instructions do not remove shortcuts from the Start Menu or anywhere else.  You’ll need to do that yourself.

[1] http://groups.google.com/group/microsoft.public.windows.powershell/browse_thread/thread/51a54e7de0ed5d1f/eaba9eb2c0d772ec

[2] http://blogs.msdn.com/powershell/archive/2007/01/09/behind-powershell-installer-for-windows-xp-windows-server-2003.aspx

[3] http://marcoshaw.blogspot.com/2008/06/powershell-v2-ctpctp2-error-error.html

The VS2008 remote debug transport (MSVSMON.EXE) does not support Silverlight?

Monday, April 20th, 2009

So, a Silverlight app we recently deployed into production works great across a wide variety of machines, browsers, and even OS platforms…except for one poor customer.  For him the app crashes soon after loading, with a strange exception deep in the SL runtime.  Sounds like a job for the remote debugger, right?

BzztI think we don't support remote Windows debugging for Silverlight.  Can anyone confirm or deny?

It sure doesn’t work for me.  I can choose a browser from the list of processes and “Silverlight code” from the list of debuggers, but I always get “Unable to attach to the process.”