Skip to content

Commit 78bc910

Browse files
committed
Add language support
Adds support for Install-Language and Set-SystemPreferredUILanguage; Requires minimum Windows build
1 parent 9fa02e8 commit 78bc910

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,6 @@
8080
"Winlogon",
8181
"WINWORD",
8282
"Zune"
83-
]
83+
],
84+
"pester.autoRunOnSave": false
8485
}

src/Install-Defaults.ps1

+41-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ param (
3131
[System.String] $Helplink = "https://stealthpuppy.com/image-customise/",
3232

3333
[Parameter(Mandatory = $False)]
34-
[System.String[]] $Properties = @("General", "Registry", "Paths", "StartMenu", "Features", "Capabilities", "Packages", "AppX"),
34+
[System.String[]] $Properties = @("General", "Registry", "Paths", "StartMenu", "Features", "Capabilities", "Packages", "AppX", "Language"),
3535

3636
[Parameter(Mandatory = $False)]
37-
[System.String] $AppxMode = "Block"
37+
[System.String] $AppxMode = "Block",
38+
39+
[Parameter(Mandatory = $False)]
40+
[System.String] $Language = "en-AU"
3841
)
3942

4043
#region Restart if running in a 32-bit session
@@ -60,7 +63,7 @@ if (!([System.Environment]::Is64BitProcess)) {
6063
#region Functions
6164
function New-ScriptEventLog ($EventLog, $Property) {
6265
$params = @{
63-
LogName = "Customised Defaults"
66+
LogName = $EventLog
6467
Source = $Property
6568
ErrorAction = "SilentlyContinue"
6669
}
@@ -619,7 +622,6 @@ try {
619622
}
620623
#endregion
621624

622-
623625
# If on a client OS, run the script to remove AppX; UWP apps
624626
if ($Platform -eq "Client") {
625627

@@ -639,6 +641,41 @@ try {
639641
$Object = ([PSCustomObject]@{Name = "Remove-AppxApps.ps1"; Value = $RemovedApps.Name; Result = 0 })
640642
Write-ToEventLog -Property "AppX" -Object $Object
641643
}
644+
645+
# Set language support
646+
if ($Language -eq "Skip") {
647+
Write-Verbose -Message "Skip install language support."
648+
Write-ToEventLog -Property "Language" -Object ([PSCustomObject]@{Name = "Install language"; Value = "Skipped"; Result = 0})
649+
}
650+
else {
651+
try {
652+
$params = @{
653+
Language = $Language
654+
CopyToSettings = $True
655+
ExcludeFeatures = $False
656+
}
657+
Write-Verbose -Message "Install language: $Language."
658+
$Msg = "Success"; $Result = 0
659+
Install-Language @params | Out-Null
660+
}
661+
catch {
662+
$Msg = $_.Exception.Message; $Result = 1
663+
}
664+
Write-ToEventLog -Property "Language" -Object ([PSCustomObject]@{Name = "Install language: $Language"; Value = $Msg; Result = $Result })
665+
try {
666+
$params = @{
667+
Language = $Language
668+
PassThru = $False
669+
}
670+
Write-Verbose -Message "Set system language: $Language."
671+
$Msg = "Success"; $Result = 0
672+
Set-SystemPreferredUILanguage @params
673+
}
674+
catch {
675+
$Msg = $_.Exception.Message; $Result = 1
676+
}
677+
Write-ToEventLog -Property "Language" -Object ([PSCustomObject]@{Name = "Set system language: $Language"; Value = $Msg; Result = $Result })
678+
}
642679
}
643680
}
644681
catch {

0 commit comments

Comments
 (0)