This project is read-only.

Messages displayed in the (Primary) Language of the current Logged on User

Topics: Archive - Deployment Scripts
Mar 24, 2015 at 7:24 PM
Edited Mar 24, 2015 at 11:12 PM
To Display Messages in a Language there are 2 options:
Use the Culture or use override for the Default Language in the XML for All users
  • Our App (installed via SCCM) runs under System Account (So the System Account Culture is retrieved - I think)
    Correct me if i'm wrong :)
We have Languages Packs installed.
I Like to have the messages displayed in the (Primary) Language of the current Logged on User

Found out that the Primary set Language is set here:
HKEY_CURRENT_USER\Control Panel\International\User Profile\Languages
Which gives e.g. : "nl-NL en-US"
The first Culture nl-NL in the value is always the Primary Language set by the user.

Thought about using the Override value in the XML and use the "$configInstallationUILanguageOverride" section in the Main script to fill in the "UI_Messages_<Language>" with an If / Else construction
e.g.
<InstallationUI_LanguageOverride>HKU</InstallationUI_LanguageOverride>
If HKU then get the current users Primary Language

Tried this to fill the $xmlUIMessageLanguage with "UI_Messages_<Primary Language>":
$DOMAIN = [string]$usersLoggedOn.Split('\')[[string]$usersLoggedOn.Split('\').Count-2]
$USER = [string]$usersLoggedOn.Split('\')[[string]$usersLoggedOn.Split('\').Count-1]
$HKUSID = ([wmi]"win32_userAccount.Domain='$DOMAIN',Name='$USER'").sid

$HKULanguages = Get-RegistryKey -SID $HKUSID "HKEY_CURRENT_USER\Control Panel\International\User Profile" -Value 'Languages'

$HKUPrimaryLanguageShort = $HKULanguages.substring(0,2)[0].ToUpper() 
[string]$xmlUIMessageLanguage = "UI_Messages_$HKUPrimaryLanguageShort"

## Write-Host $xmlUIMessageLanguage
In this case: $xmlUIMessageLanguage gives the wished result UI_Messages_NL
Yeah!

So I got it to work in Powershell ISE manually, but when I deploy with SCCM the App failed on:
$HKULanguages = Get-RegistryKey -SID $HKUSID "HKEY_CURRENT_USER\Control Panel\International\User Profile" -Value 'Languages'
Any other ideas getting this to work ?

Kind regards
Edwin
Developer
Mar 25, 2015 at 5:15 AM
What was the error? Can't really help without that information. The ISE probably loads functions and make them available for you to use no matter where you choose to use them. However, when you deploy a script, you have to make sure you use a function after you have declared it. Make sure you're using the Get-RegistryKey function after the section where functions are declared.
Mar 25, 2015 at 11:26 AM

Hello Mmashwani,

Thanks for your fast reaction !

What do you think of the (to be build) feature?

What’s the normal way of working. Must I react via the Blog or can this done via Email?

Or .. e.g. If we have the answer then post it to the blog?

I’ll check the PS again. I’m a new PowerSheller.

Or…Can I sent you the draft PS1 file. So that you can advise or use the feature?

Kind regards,

Edwin

Developer
Mar 25, 2015 at 11:59 AM
I think it's a good feature.

Let's keep the conversation in the thread. You can private message me with a link to logs. If you can post the error message here when we can probably figure out what the problem is without looking at logs or the script. The error messages are usually pretty descriptive.
Mar 25, 2015 at 12:04 PM

OK I will do that.

It just says failed in Software center.

Where can I find the Errorlog?

When I start the script manual I can find a log under c:\windows\Logs\Software?

But deploying with SCCM the log is not made in c:\windows\Logs\Software.

Regards Edwin

Developer
Mar 25, 2015 at 12:45 PM
The log file will be in what ever location you configured in your XMl configuration file. I don't see any reason why there would not be a log file unless you specifically disabled it.
Mar 25, 2015 at 6:34 PM
Edited Mar 25, 2015 at 9:52 PM
I still have Default settings in the XAppDeployToolkitConfig.xml:
<Toolkit_LogPath>$envWinDir\Logs\Software</Toolkit_LogPath>
I only changed the XAppDeployToolkitConfig.xml (for the new to created feature) with the value HKU
<InstallationUI_LanguageOverride>HKU</InstallationUI_LanguageOverride> 
When I start the script manualy with Powershell ISE the logfile gets there.
With SCCM it won't and it Fails. I understand why now.

I think the answer is in your Earlier post:
mmashwani wrote:
However, when you deploy a script, you have to make sure you use a function after you have declared it. Make sure you're using the Get-RegistryKey function after the section where functions are declared.
Because I have the
$HKULanguages = Get-RegistryKey -SID $HKUSID "HKEY_CURRENT_USER\Control Panel\International\User Profile" -Value 'Languages'
Just below the
# Override the detected language if the override option was specified in the XML config file Section
of the AppDeployToolkitMain.ps1
Which is indeed before the #region Function Get-RegistryKey

I need the Get-registrykey function (especially the Get-RegistryKey -SID) to fill in the Variables (which are earlier then the Get-registrykey function)

Can you give me advise?
  • Powershell Rule: Move the Get-registrykey function before the Variables ?
  • or is there an other way to do this?
  • or must I use other default Windows Commands instead... :( ?
Developer
Mar 25, 2015 at 11:37 PM
Move your code towards the end of AppDeployToolkitMain.ps1 right after all of the functions have been defined.
Developer
Apr 1, 2015 at 10:56 AM
I have added this feature to latest 3.6.1 beta version of the toolkit. You can find it under the "Source Code" tab of this site. Please test and let me know if it works as expected.
Apr 1, 2015 at 4:34 PM
Edited Apr 1, 2015 at 4:35 PM
Hello Mmashwani,

Great news!
Thanks for picking this up.
I found our suggested $HKUPrimaryLanguageShort code in the 3.6.1 Source :)

Summarization:
  • The Language will be the Primary Language of the logged on User.
  • When no user is logged on the Get-Culture is picked up.
  • When the Primary Language of the logged on User or Get-Culture (value) is not available (in the AppDeployToolkitConfig.xml) then it falls back to EN
  • <InstallationUI_LanguageOverride></InstallationUI_LanguageOverride> in AppDeployToolkitConfig.xml can be used to override all found Languages
I will test this Beta as soon as possible.

Kind regards, Edwin