. Skip to main content

Daniel Nix

Daniel Nix

Powershell: get current user keyboard settings

2 min read

Powershell script to get the last user logged in and the keyboard preload setting (Win7)

Import-Module ActiveDirectory
Import-Module PSRemoteRegistry

$computers = Get-ADComputer -Filter 'ObjectClass -eq "Computer"'  -searchbase $path -searchscope 2 | Select -Expand DNSHostName

forEach ($computer in $computers){
    if (Test-Connection -computername $computer -Quiet) {
        $logonname = Get-RegValue -ComputerName $computer -Hive LocalMachine  -Key "SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI" -Value "LastLoggedOnSAMUser"
        $preload =   Get-RegValue -ComputerName $computer -Hive CurrentUser  -Key "Keyboard Layout\Preload" -Value 1
        $sub =       Get-RegValue -ComputerName $computer -Hive CurrentUser -Key "Keyboard Layout\Substitutes" -Value $preload.Data
        $reg =       Get-RegValue -ComputerName $computer -Hive LocalMachine -Key "SYSTEM\ControlSet001\Control\Keyboard Layouts\$($sub.Data)" -Value "layout text"

        $result = $computer + ';' + $logonname.Data + ';' + $reg.Data
        Write-Host $result
        $result | Add-Content 'UserKbd.csv'


Make sure the file UsersKbd.csv exists (or create at beginning).

Needs module PSRemoteRegistry.

It takes the computer name from your AD, checks that's online. Takes the registry key for the last logged on user.

For the keyboard, it takes the keyboard code of the logon screen, takes the substitute and gets the human readable layout.

Daniel Nix

Daniel Nix

Daniel Nix

Daniel Nix

Daniel Nix

What Happens in Sweden when you scream out the windows at 10pm? http://nixis.me/79

Daniel Nix

Canon separator page

1 min read

so if you need a separator page for your print jobs on Canon ADV copiers. For my copiers pcl.sep did do the job.

create a share \\share\sepFiles* where your .sep file will be placed.

Open the driver settings -> advanced ->separator page

Browse to the file.

Here an example file :

\U\LJob : \I
\U\LOwner: \N
\U\LDate: \D
\U\LTime: \T

This will print

Day date


More info about pcl.sep language on MS


* this sepFiles folder is mandatory if you place this file outside c:\windows\system32