When I was patching a production SharePoint farm, the Configuration Wizard failed in three machines due to missing packages. I had verified those packages and I could confirm that they are already installed. After quick investigation, I found that several of the installer cache files are missing from the Windows Installer cache files "C:\Windows\Installer".
For such issue, you have two options:
- Copy the missing files from another healthy server
Such solution is a nightmare, because the files are located on other servers with different names, so, even if you copied all the contents of the “Installer” folder from different healthy machine, will not resolve the problem.
- Rebuild the server
This is the optimum solution but would cost time and sometimes money.
All those files' information are restored on the windows registry, so, there must be away to identify the missing files.
I had searched online hopefully to find a script which can identify the missing files from the registry, but unfortunately, I didn’t find a decisive script which can do it. I could find some scripts with VBS language which can precisely identify the MSP (patch) files with the unique revision number which can be used to identify the missing files on other destination, but they were not precise to identify the MSI (Package) files.
I had found online many are complaining about the same issue when they upgrade/patch SharePoint, SQL or other enterprise software.
Hence, I had built my PowerShell script “Restore-InstallerFiles.ps1” which is capable to identify the missing files and/or restore them from different sources such as local folder, shared folder or another machine which can be accessed from the target machine.
Instructions:
- Click here to download the script.
- Copy the script to the target machine.
- Make sure that the current local identity has Read/Write permission on the "C:\Windows\Installer" folder of the target machine, and Read permission on the source folder (If the source was a machine name, make sure you have read permission on the local folder "C:\Windows\Installer" inside the source machine).
- Execute the script locally on the target machine with the following parameters and as illustrated with the following examples.
Minimum System Requirements:
PowerShell Version: 2.0
CLR (Microsoft .Net Framework) Version: 2.0
Script Parameters:
.PARAMETER SourceMachine
Alias: M
Data Type: System.String[]
Mandatory: True
Description: The name of the source machine(s) where the script can find the missing files there, and restore them to the target machine with the correct names.
Example(s): "Machine1_Name", "Machine2_Name", "Machine3_Name", "Machine4_Name"
Default Value: N/A
Notes: This parameter is a mandatory if the the "SourceFolder" not specified.
.PARAMETER SourceFolder
Alias: F
Data Type: System.String[]
Mandatory: True
Description: The source folder(s) where the script can find the missing files there, and restore them to the target machine with the correct names.
Example(s): "D\installer_bak", "D\installer_bak2", "E\installer_bak3"
Default Value: N/A
Notes: This parameter is a mandatory if the the "SourceMachine" not specified.
.PARAMETER ScanOnly
Alias: S
Data Type: Switch
Mandatory: True
Description: Only scan for the missing files and then display them without attempting the fix.
Example(s): N/A
Default Value: N/A
Notes: This parameter is a mandatory and cannot be combined with the two parameters "SourceMachine" or "SourceFolder".
.PARAMETER LogFile
Alias: L
Data Type: System.String
Mandatory: False
Description: The location of the output transcript logging file.
Example(s): "D:\Log.txt"
Default Value: N/A
Notes: N/A
Examples:
.\Restore-InstallerFiles -SourceMachine "Machine1", "Machine2", "Machine3";
.\Restore-InstallerFiles -SourceFolder "D:\InstallerFiles", "E:\InstallerFiles", "\\MachineX\D$\MSI Files";
.\Restore-InstallerFiles -SourceFolder "D:\InstallerFiles", "E:\InstallerFiles", "D:\InstallerFiles2" -LogFile "D:\Log.txt";
For further details, please run Get-Help .\Restore-InstallerFiles.ps1 -Detailed;.
- In the following screenshot, I'm using the script to scan for the missing files, which returned 0 missing files on that machine.

- In the following screenshot, I'm using the script to scan for the missing files, which returned 7 missing files on that machine.

- In the following screenshot, I'm using the script to restore the missing files from a local folder which copy of the installer cache files from different machine.

Updates:
Date: March, 11th, 2017
Update(s): Backward compatibility with PS version 2.0 and CLR (Microsoft .Net Framework) version 2.0.
Fixing the bug in the internal function "Get-FileRevisionNumber" which was related with PS version backward compatibility.