windowspowershellinternationalization

Powershell: Correct syntax of Install-Language?


I'm trying to programmatically deploy "Basic Typing" for a range of languages via PowerShell to a fleet of Windows PCs. Although I am a coder, I don't have much experience in PowerShell itself.

Looking at these articles:

https://woshub.com/install-language-pack-windows-powershell/

https://learn.microsoft.com/en-us/powershell/module/languagepackmanagement/install-language?view=windowsserver2022-ps

I gather that I want to run something like this:

Install-Language -Language da-DK -ExcludeFeatures OCR, TextToSpeech, Handwriting

However, the above gives me an error:

A positional parameter cannot be found that accepts the argument 'OCR'

I assume that I'm not using the correct syntax/formatting, or the values that I'm using are not correct. Frustratingly, the MS documentation doesn't list the acceptable values for ExcludeFeatures, nor does any of its examples show how it's used.

Any help or advice would be much appreciated, thanks.

I've tried running Install-Language with only OCR or TextToSpeech as an argument for -ExcludeFeatures, but that gives the same error.

I've even tried to just run

Install-Language en-US

But I get an error "Failed to Install Language. Error Code -2147418113". This might be network access or something blocking Windows Updates, so I'll troubleshoot that separately...


Solution


  • In other words:

    Therefore, run the following from an elevated session (run as administrator):

    #requires -RunAsAdministrator
    
    # NOTE: Took almost 7 minutes (!) to complete on my W11 22H2 machine
    Install-Language -Language da-DK -ExcludeFeatures
    

    [1] Technically, you may pass $true or $false as an argument, separated with : (e.g, -ExcludeFeatures:$true), which is primarily used when programmatically constructing arguments with the Boolean provided via a variable or expression; -ExcludeFeatures:$true is in effect the same as just -ExcludeFeatures, and -ExcludeFeatures:false is - typically and in this case - the same as not specifying -ExcludeFeatures. See this answer for more information.