exception when running Deploy-Application.ps1 via TFS Release Management

Hello,

if I run Deploy-Application.ps1 via TFS Release Management Step (Powershell on Target Machines)
It is called via WinRM PowerShellOnTargetMachines.ps1

I get some strange problems.

2016-04-15T12:22:29.2144968Z 	 Deployment started on target machine...
2016-04-15T12:22:29.2144968Z System.AggregateException: Failed to execute the powershell script. Consult the logs below for details of the error.
2016-04-15T12:22:29.2144968Z Module [...\Dev\Prerequisite\SQLFX_x64_April_2014\AppDeployToolkit\AppDeployToolkitMain.ps1] failed to load: 
2016-04-15T12:22:29.2144968Z Cannot convert value "[04-15-2016 14:22:28.234] [Initialization] [Get-RegistryKey] :: Registry key [[04-15-2016 14:22:28.234] [Initialization] [Convert-RegistryPath] :: Return fully qualified registry key path [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MUI\Settings]. Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MUI\Settings] does not exist. Return $null." to type "System.Globalization.CultureInfo". Error: "Culture is not supported.
2016-04-15T12:22:29.2144968Z Parameter name: name
2016-04-15T12:22:29.2144968Z [04-15-2016 14:22:28.234] [Initialization] [Get-RegistryKey] :: Registry key [[04-15-2016 14:22:28.234] [Initialization] [Convert-RegistryPath] :: Return fully qualified registry key path [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MUI\Settings]. Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MUI\Settings] does not exist. Return $null. is an invalid culture identifier."
2016-04-15T12:22:29.2144968Z  
2016-04-15T12:22:29.2144968Z At ...\Dev\Prerequisite\SQLFX_x64_April_2014\AppDeployToolkit\AppDeployToolkitMain.ps1:310 char:101
2016-04-15T12:22:29.2144968Z + 			[Globalization.CultureInfo]$PrimaryWindowsUILanguage = [Globalization.CultureInfo]($HKULanguages[ <<<< 0])
2016-04-15T12:22:29.2144968Z  +
2016-04-15T12:22:29.2144968Z At line:1 char:2
2016-04-15T12:22:29.2144968Z + . <<<<  "...\Dev\Prerequisite\SQLFX_x64_April_2014\Deploy-Application.ps1" -DeploymentType "Install" -DeployMode "Silent"
2016-04-15T12:22:29.2144968Z  CategoryInfo :NotSpecified: (:) [Write-Error], WriteErrorException
2016-04-15T12:22:29.2144968Z  FullyQualifiedErrorId :Microsoft.PowerShell.Commands.WriteErrorException,Deploy-Application.ps1
2016-04-15T12:22:29.2144968Z  ---> Microsoft.PowerShell.Commands.WriteErrorException: Module [...\Dev\Prerequisite\SQLFX_x64_April_2014\AppDeployToolkit\AppDeployToolkitMain.ps1] failed to load: 
2016-04-15T12:22:29.2301385Z Cannot convert value "[04-15-2016 14:22:28.234] [Initialization] [Get-RegistryKey] :: Registry key [[04-15-2016 14:22:28.234] [Initialization] [Convert-RegistryPath] :: Return fully qualified registry key path [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MUI\Settings]. Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MUI\Settings] does not exist. Return $null." to type "System.Globalization.CultureInfo". Error: "Culture is not supported.
2016-04-15T12:22:29.2301385Z Parameter name: name
2016-04-15T12:22:29.2301385Z [04-15-2016 14:22:28.234] [Initialization] [Get-RegistryKey] :: Registry key [[04-15-2016 14:22:28.234] [Initialization] [Convert-RegistryPath] :: Return fully qualified registry key path [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MUI\Settings]. Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MUI\Settings] does not exist. Return $null. is an invalid culture identifier."
2016-04-15T12:22:29.2301385Z  
2016-04-15T12:22:29.2301385Z At ...\Dev\Prerequisite\SQLFX_x64_April_2014\AppDeployToolkit\AppDeployToolkitMain.ps1:310 char:101
2016-04-15T12:22:29.2301385Z + 			[Globalization.CultureInfo]$PrimaryWindowsUILanguage = [Globalization.CultureInfo]($HKULanguages[ <<<< 0])
2016-04-15T12:22:29.2301385Z    --- End of inner exception stack trace ---
2016-04-15T12:22:29.2301385Z    at Microsoft.VisualStudio.Services.DevTestLabs.RemoteDeployer.Deployment.PowershellExecutor.Invoke(String errorContextMessage, Boolean writeResultToLog, Boolean isCancellable, ActionPreference errorActionPreference)
2016-04-15T12:22:29.2301385Z    at Microsoft.VisualStudio.Services.DevTestLabs.RemoteDeployer.Deployment.ScriptExecutor.ExecuteScript(IPowerShell powerShell, String script, String arguments, Boolean isScriptDotSourced, Boolean useHttp)
2016-04-15T12:22:29.2301385Z    at Microsoft.VisualStudio.Services.DevTestLabs.RemoteDeployer.Deployment.DeploymentService.RunPowerShellScripts(DeploymentMachineSpecification deploymentMachine, ScriptSpecification scriptSpecification, ScriptSpecification initializationScriptSpecification, String applicationPath, IPowerShell powerShellSession)
2016-04-15T12:22:29.2301385Z ---> (Inner Exception #0) Microsoft.PowerShell.Commands.WriteErrorException: Module [...\Dev\Prerequisite\SQLFX_x64_April_2014\AppDeployToolkit\AppDeployToolkitMain.ps1] failed to load: 
2016-04-15T12:22:29.2301385Z Cannot convert value "[04-15-2016 14:22:28.234] [Initialization] [Get-RegistryKey] :: Registry key [[04-15-2016 14:22:28.234] [Initialization] [Convert-RegistryPath] :: Return fully qualified registry key path [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MUI\Settings]. Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MUI\Settings] does not exist. Return $null." to type "System.Globalization.CultureInfo". Error: "Culture is not supported.
2016-04-15T12:22:29.2301385Z Parameter name: name
2016-04-15T12:22:29.2301385Z [04-15-2016 14:22:28.234] [Initialization] [Get-RegistryKey] :: Registry key [[04-15-2016 14:22:28.234] [Initialization] [Convert-RegistryPath] :: Return fully qualified registry key path [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MUI\Settings]. Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MUI\Settings] does not exist. Return $null. is an invalid culture identifier."
2016-04-15T12:22:29.2301385Z  
2016-04-15T12:22:29.2301385Z At ...\Dev\Prerequisite\SQLFX_x64_April_2014\AppDeployToolkit\AppDeployToolkitMain.ps1:310 char:101
2016-04-15T12:22:29.2301385Z + 			[Globalization.CultureInfo]$PrimaryWindowsUILanguage = [Globalization.CultureInfo]($HKULanguages[ <<<< 0])<---

$HKULanguages[0] is null, my quick fix was the following:

line arround 309:
If ($HKULanguages) {

[Globalization.CultureInfo]$PrimaryWindowsUILanguage = Globalization.CultureInfo

[string]$HKUPrimaryLanguageShort = $PrimaryWindowsUILanguage.TwoLetterISOLanguageName.ToUpper()

    [string]$HKUPrimaryLanguageShort = "EN"

I got a similar problem with $dpiPixels

2016-04-15T14:07:21.9455573Z ##[error]Module [...\AppDeployToolkit\AppDeployToolkitMain.ps1] failed to load: 
2016-04-15T14:07:21.9455573Z ##[error]Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Int32".
2016-04-15T14:07:21.9455573Z ##[error] 
2016-04-15T14:07:21.9455573Z ##[error]At ...\AppDeployToolkit\AppDeployToolkitMain.ps1:436 char:20
2016-04-15T14:07:21.9455573Z ##[error]+ 		[int32]$dpiPixels <<<<  = Get-RegistryKey -Key 'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI' -Value 'LogPixels' For more info please refer to http://aka.ms/powershellontargetmachinesreadme

I think there is a general problem I don’t understand.

Any ideas?

greetings
Carsten