• Published
  • 1 min

Fixing the "Assembly redirect for $file" Powershell bug for EPiServer 6 in Windows 8

A bug in the Powershell script for EPiServer 6 will make Deployment Center throw an error on Windows 8. Here's a quickfix until an official patch is released.

Unescaped variables in Powershell script

On Windows 8, you may have encountered this error when trying to create a new EPiServer 6 site:

At C:\Program Files (x86)\EPiServer\Framework\6.2.267.1\Install\System Scripts\Install Site (SqlServer).ps1:211 char:32
+ echo "Assembly redirect for $file: 1.0.0.0-$fileVerssion"
+ ~~~~~~
System.Management.Automation.ParentContainsErrorRecordException: At C:\Program Files (x86)\EPiServer\Framework\6.2.267.1\Install\System Scripts\Install Site (SqlServer).ps1:211 char:32
+ echo "Assembly redirect for $file: 1.0.0.0-$fileVerssion"
+ ~~~~~~
Variable reference is not valid. ':' was not followed by a valid variable name character. Consider using ${} to delimit the name.

This is caused by the unescaped variable names ($file and $fileVerssion) which makes Powershell throw an error and halt Deployment Center. (Windows 7 uses Powershell v2 which doesn't complain about this, while Windows 8 uses Powershell v3).

This will occur on Windows 8 when using the EPiServer 6 download package that contains v6.1.379.502 (or higher) of the cms components and v6.2.267.1 of the shared components.

It has been reported as a bug and will probably be patched soon.

In the meantime, here's a...

Quickfix

1. Find the Powershell script that comes with EPiServer 6: (make a backup copy :-)
C:\Program Files (x86)\EPiServer\Framework\6.2.267.1\Install\System Scripts\Install Site (SqlServer).ps1.

2. Edit the script and go to line 211:
echo "Assembly redirect for $file: 1.0.0.0-$fileVerssion" 

Either fix the escaping (add curly braces):
echo "Assembly redirect for ${file}: 1.0.0.0-${fileVerssion}"Or...Remove the line completely (it's just info logging, not critical for the script)


3. Since we are tampering with a signed script, we need to remove the digital signature.
Go to the end of the script and remove the entire SIG block
Save the file (overwrite the old one).

4. We need to tell Powershell to accept unsigned scripts by changing the ExecutionPolicy. 
Search for "Windows Powershell" from your start screen, then run as Administrator.
This will open a powershell console window.  

Paste and run the following command (answer Yes if you get a confirmation prompt)
C:\Windows\System32\WindowsPowerShell\v1.0\powershell set-executionpolicy unrestricted

Update: As Eric notes in the comments section, you might need to specify executionpolicy for the current user, which is done by running the following command:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell set-executionpolicy unrestricted -scope CurrentUser

Note: Powershell has separate execution policies for 32- and 64-bit applications. Deployment Center is 32-bit, so we only need to change that policy. For reference, changing the policy for 64-bit would be:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell set-executionpolicy unrestricted

5. Run Deployment Center and install your EPiServer 6 site. Should work fine now.