Tag: PowerShell

How to get rid of multiple keyboard layouts in Windows 11 using Remediations in Intune, or PowerShell

I always use English (en-US) installation media for Windows and have always had that as a preferred choice as I prefer to run Windows in English. Many customers do that as well. The problem with that is that every time a device is reset or freshly installed via the Autopilot flow, it will result in multiple keyboard layouts, as it will have English layout and then also the Swedish keyboard layout in my cases.

It is annoying to have these multiple choices of keyboard layouts as sometimes, and when you least expect it, it defaults back to English keyboard layout which is annoying. Plus, and although it is not a big deal, it is also nice to get rid of the UI elements in the system tray by resolving this finally.

Physically, I will always only have a Swedish keyboard so that is the only keyboard layout I want!

PowerShell to the rescue

There are some PowerShell cmdlets in Windows 11 (and Windows Server) to help you manage the situation, because honestly, the Language & region settings page in Windows is quite messy. The below cmdlet will get you results that show your current situation:

PowerShell
Get-WinUserLanguageList

To make sure that you get only the keyboard layout you want (sv-SE i.e., Swedish for example), this is the command:

PowerShell
Set-WinUserLanguageList sv-SE -Force

Depending on what language packs you have on the device, it might switch the Windows Display Language to that language and to prevent that, use this cmdlet:

PowerShell
Set-WinUILanguageOverride -Language en-US

Remediation via Intune

Of course, you can remediate this automatically via Intune. Download the detection and remediation scripts from IntuneRemediationScripts/Set-KeyboardLayout at main · AndreasStenhall/IntuneRemediationScripts

Microsoft Learn reference to PowerShell : International Module | Microsoft Learn

Checking Win32 application runtime dependencies in Windows 10

There are new WMI classes in Windows 10 that can be used to collect software inventory. The information can be displayed using PowerShell. Also, there is a feature that inventories what framework or runtime an application is dependent on, for instance which version of .NET Framework or Visual C++ Runtime and it can even see if there are dependencies for OpenSSL. Imagine having these feature in place when the HeartBleed bug appeared a few years ago.

Display all installed applications on a Windows 10 machine:

Get-WMIObject Win32_Installedwin32Program | select Name, Version, ProgramID | out-GridView

Display all apps and dependent frameworks on a Windows 10 machine for a specific application (replace the ProgramID in the filter section with another one from the above example), and make sure everything is on one row:

Get-WMIObject Win32_InstalledProgramFramework -Filter "ProgramID = '00000b9c648fd31856f33503b3647b005e740000ffff'" | select ProgramID, FrameworkName, FrameworkVersion | out-GridView

or to bake them together to get both the application name and associated frameworks:

$Programs = Get-WMIObject Win32_InstalledWin32Program | select Name,ProgramID
$result = foreach ($Program in $Programs) {
$ProgramID = $program.programID
$Name = $program.Name
$FMapp = Get-WMIObject Win32_InstalledProgramFramework -Filter "ProgramID = '$programID'"
foreach ($FM in $FMapp) {
$out = new-object psobject
$out | add-member noteproperty Name $name
$out | add-member noteproperty ProgramID $ProgramID
$out | add-member noteproperty FrameworkPublisher $FM.FrameworkPublisher
$out | add-member noteproperty FrameworkName $FM.FrameworkName
$out | add-member noteproperty FrameworkVersion $FM.FrameworkVersion
$out
}
}
$result | out-gridView

Now, happy hunting for runtime dependencies!

Joining a computer to the domain using PowerShell

Bumped into a problem where the user account used to join machines to the domain was limited to joining the machines to a particular OU. That makes it hard to just join a machine using the good old way i.e. System Properties and then joining the domain. This will not let me specify the OU to join and will fail and probably this is the intention with this design at this particular customer.

But anyway thanks to a great builtin PowerShell cmdlet in Windows 7 I could get the job done in seconds. Keep in mind :)

Add-Computer -DomainName contoso.com -Credential contoso.com\joinDomainAccount -OUPath "OU=Company,DC=contoso,DC=com"

Reference: Microsoft TechNet