Automating the world one-liner at a time…
The information here relates to Windows PowerShell 1.0 installer on downlevel platforms (XP SP2, W2K3 SP1 and above).
The job of installers is to create an environment on a user’s machine, so that the underlying software works seamlessly on the machine. Typically most installation scripts copies some files and sets some registry keys. This appears to be simple on the first hand but it gets little complicated if you bring servicing into picture. Installation script must ensure that the underlying software is serviceable.
Herein I will try to explain what Windows PowerShell installer does behind the scenes.
Choose an appropriate Powershell installer depending on the OS platform and language from http://www.microsoft.com/powershell. The following operations are performed by the installation software:
1. Check if Powershell can be installed. Installation will fail if any of the following is true:
(a) Only an administrator can install PowerShell. So for non-administrator the installation will fail.
(b) Supported OS. Remember there is a separate installation package for OS Platform + language
(c) PowerShell is already installed
(d) CLR is not installed
2. Give an opportunity to user to see “End User License Agreement”. Depending upon circumstances, this will give an opportunity to the user to either go ahead with the installation or cancel the installation task.
3. Install Windows PowerShell related files (binaries/text files) onto user’s machine.
For list of files installed see http://support.microsoft.com/?kbid=926139
All the files will be copied to %windir%\system32\WindowsPowerShell\v1.0 directory.
Let’s call this PSHOME. All the language neutral files will be copied to PSHOME and language dependent files will be copied to PSHOME\<lang code> sub-directory. All the help related content + native unmanaged resources are language dependent as these really are unique per language. For example, a German version of Windows PowerShell should show help in German whereas an English version should show in English.
4. Add Windows PowerShell specific registry keys.
PowerShell environment depends on the existence of the following registry key and subkeys.
Let’s go through each of these subkeys:
a. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1 Install
The existence of this key will tell users that PowerShell is installed
b. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1 PID
This key will help our Product Support team to categorize customer calls to a specific product and this key also allows other dependent products to distinguish between different versions of PowerShell ie., RC2 and RTM
RC2 PowerShell will set this key information to 89393-100-0001260-00301
RTM PowerShell will set this key information to 89383-100-0001260-04309
c. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\<Lang code> Install
The existence of this key will let users know what languages the installed powershell supports. For example HKLM\SOFTWARE\Microsoft\PowerShell\1\1033, Install = 1 means English version of PowerShell is installed.
Language codes for other languages:
2052 zh-CHS (Chinese-Simplified), 1028 zh-CHT (Chinese-Traditional),1031 de(German),1033 en(English),3082 es(Spanish),1036 fr(French),1040 it(Italian),1041 ja(Japanese),1042 ko(Korean),1046 pt-BR(Portugese-Brazil),1049 ru(Russian)
This key contains information used by PowerShell engine. It contains information like PowerShell Version, Application Base and CLR version.
The information under “ShellIds” relate to different Custom Shells. The main powershell.exe implements a console host that uses PowerShell engine functionality. The shell ID for this console powershell.exe is “Microsoft.PowerShell”. The ID is defined inside the custom shell at the build time.
f. HKLM\SYSTEM\CurrentControlSet\Services\Eventlog\Windows PowerShell
This contains Powershell Eventlog related information.
g. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows PowerShell 1.0
This contains PowerShell installation related information like “Installed By”, Date of Installation. All this information typically shows up in Add/Remove programs. Notice Uninstallation command here.
h. Associate.ps1,.ps1xml extensions to text editor (see for entries like HKCR\.ps1 )
i. Associated .psc1 extension to PowerShell.exe
j. Safeguard .ps1, .ps1xml, .psc1 files so that AssocIsDangerous() returns true
k. Add Powershell cryptography related registry information under
HKLM\Software\Microsoft\Cryptography\OID\EncodingType 0\ (see for entries with GUID "603BCC1F-4B59-4E08-B724-D2C6297EF351”)
5. Add Windows PowerShell 1.0 shortcut sub-directory to the directory pointed to by CSIDL_COMMON_PROGRAMS (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp)
6. GAC+Ngen PowerShell managed binaries.
Ie., System.Management.Automation.dll, System.Management.Automation.resources.dll,
After the installation powershell binaries will be queued with priority 3 in the ngen queue. To ngen them right away use the following command:
%windir%\microsoft.net\framework\v2.0.50727\ngen.exe executeQueuedItems 3
[Note: This will execute all the items with priority 3.]
7. Add powershell application base path to the PATH environment variable
8. Add .psc1 to PATHEXT variable
1. PowerShell uninstaller is available under Control Panel->Add / Remove Programs. One has to select “Show Updates” checkbox to see the powershell entry. This is because PowerShell is an Optional Windows Component and is release as an Optional Windows Software Update.
2. Uninstallation will fail if the following is true:
(a) CLR is not installed. We check for CLR existence during uninstallation as we have to ungac/ngen uninstall powershell related managed binaries. CLR uninstallation will not clean GAC which might result in servicing related issues.
3. Ngen uninstall PowerShell related managed binaries
4. Gac uninstall PowerShell related managed binaries
5. Remove powershell.exe path from PATH environment variable
6. Remove .psc1 from PATHEXT environment variable.
7. Uninstall registry keys added by installer
8. Uninstall files from %windir%\system32\WindowsPowerShell\v1.0
9. Remove Shortcut
10. Uninstaller cleans files, so if any product file is in use at the time of uninstallation a user may be prompted to restart. The restart operation can be delayed.
The installer / uninstaller support logging with option /log:<fullpath>. The log file will have information about files (un)installed, gac/ngen instructions etc.
On a 64-bit machine, Powershell installer will create both 64 bit environment and 32 bit environment i.e, one can use PowerShell engine services both from a 64-bit app and 32-bit app.
On a 64-bit machine the directory %windir%\system32\windowspowershell\v1.0 belongs to 64 bit powershell and %windir%\syswow64\WindowsPowerShell\v1.0 belongs to 32-bit powershell.
Similarly HKLM\Software\Microsoft\PowerShell\1 contains information related to 64-bit PowerShell and HKLM\Software\Wow6432Node\Microsoft\PowerShell\1 contains information related to 32-bit powershell.
All the files and registry keys that I explained above will be made available to the 32 bit app as well following the above logic. Ie., a 64-bit version of PowerShell.exe is under %windir%\system32\windowspowershell\v1.0 and 32-bit version is under %windir%\syswow64\WindowsPowerShell\v1.0
Note: Be careful the OS will automatically redirect calls to System32 to SysWow64 ie., from a cmd.exe(32) window if you say cd %windir%\system32\windowspowershell\ you are actually under syswow64
PowerShell managed binaries will not have these problems as PowerShell managed binaries will be installed to a global (GAC/Ngen) store and are Processor neutral.
As of Powershell 1.0 RTM, PowerShell supports 11 languages on downlevel. These are English, German, French, Japanese, Italian, Korean, Russian, Spanish, Portugal (Brazil), Chinese-Simplified, Chinese-Traditional. One can get all these language resources by installing English PowerShell first and then installing PowerShell MUI (KB926141). If you want to install only specific language see KB926140.
Related link: http://support.microsoft.com/?kbid=926140
Related link: http://support.microsoft.com/?kbid=926141
Key Take Aways for Windows XP(SP2) and Windows Server 2003(SP1) :
1. http://microsoft.com/powershell has all the information related to Powershell
2. PowerShell uninstaller is available under Control Panel->Add / Remove Programs. One has to select “Show Updates” checkbox to see the powershell entry. This is because PowerShell is an Optional Windows Component and is released as an Optional Windows Software Update.
3. Applications can programmatically detect PowerShell’s existence by using the following registry key information:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1 Install (== 1)
To detect for a particular language use:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\<langid> Install (==1)
To detect (major.minor)version of PowerShell
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine PowerShellVersion (== 1.0 for 1.0 RTM)
Windows PowerShell Development
This posting is provided "AS IS" and confers no rights or warranties.
a) when is Powershell for Win2000 available
b) why there is no Powershell Forum on MSDN ?
c) why is there no powershell.msi ?
Please advise how Powershell is uninstalled from Server 2003 x64?
1. I am new to PowerShell and would like to install it on my Vista machine. The following page http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx
I recently encountered a problem during Windows Powershell installation process.
The PSCustomSetuputil executable keeps crashing while trying to install Powershell's assemblys.
I found following lines in the log file:
64.328: Starting process: "C:\WINDOWS\$NtUninstallKB926140$\PSCustomSetupUtil.exe" /install "C:\WINDOWS\system32\WindowsPowerShell\v1.0\System.Management.Automation.dll"
71.828: Return Code = 3762507597
71.828: DoInstallation:RunInfProcesses for ProcessesToRun Failed
The error report is as following:
EventType : clr20r3 P1 : pscustomsetuputil.exe P2 : 220.127.116.11
P3 : 451ac9d9 P4 : pscustomsetuputil P5 : 18.104.22.168 P6 : 451ac9d9
P7 : e P8 : 86 P9 : system.security.security
It would seem there is a security exception trying to register the assembly, but i can't figure out what the problem is.
Any help would be greatly appreciated !
Thanks in advance
I figured out what was going wrong.
It would seem the "trust level" for the "My Computer" zone was too low... I had to adjust the level to "Full Trust", which seems to be the default value for this zone.
However, i cannot explain why this trust level was different from the default value... I don't recall changing it.
Anyway, thanks for your help and your great article on the PowerShell installer.
I am glad you were able to resolve this issue.
am i correct in thinking that there's no 32bit vista installer?
I want an msi or windows update, but i can't find either of them... Anyone out there that can point me in the right direction?
Vista installer can be found at http://support.microsoft.com/kb/928439. The installer is available for both 32bit and 64bit Vista.
I'm having a problem getting the installer to run on Win2k3 x64. It seems to do a fair bit of installation and then fails with a very non-descript error.
An error in updating your system has occurred. Select 'OK' to undo the changes that have been made.
Are you seeing this error in the middle of the installation or is the error generated by WindowsServer2003.WindowsXP-KB926139-x64-ENU.exe. Can you check if you are running this .exe from a 64-bit command window? This is a 64-bit application and this should be invoked from a 64-bit application.