header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Set Keyboard Layout based on Group Membership
Last Post 11 Aug 2010 07:33 AM by Mihail Stacanov. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
dimepopUser is Offline
New Member
New Member
Posts:5
Avatar

--
26 Jul 2010 07:56 AM
    Hi,
    I am trying to create  a powershell script that will check that if a  user is in a certain Group in AD will set his default input language to english US if he is in another he will set it up to English UK and so on..
    The script to set up the languages is like this:


    #Change Language to English US
    $RegKey ="HKCU:\keyboard Layout\Preload"
    Set-ItemProperty -path $RegKey -name 1 -value 00000409

    #Change Language to English Uk
    $RegKey ="HKCU:\keyboard Layout\Preload"
    Set-ItemProperty -path $RegKey -name 1 -value 00000809

    But how can i link each part of the script depending of Group Membership?
     For exmaple if user belong to AD Group "US Users" go to #Change Language to English US

    Thanks




    Mihail StacanovUser is Offline
    New Member
    New Member
    Posts:15
    Avatar

    --
    11 Aug 2010 07:33 AM
    #Try this script. It also checks if user exists in both groups and sends an email with warning

    $UserName = $env:username
    $Filter = "(&(objectCategory=User)(samAccountName=$UserName))"
    $Searcher = New-Object System.DirectoryServices.DirectorySearcher
    $Searcher.Filter = $Filter
    $ADUserPath = $Searcher.FindOne()
    $ADUser = $ADUserPath.GetDirectoryEntry()

    $USgroup = [ADSI] "LDAP://CN=USGroup,OU=All Groups,DC=domain"
    $UKgroup = [ADSI] "LDAP://CN=UKGroup,OU=All Groups,DC=domain"

    if (($USgroup.member -contains $ADUser.distinguishedName) -and ($UKgroup.member -contains $ADUser.distinguishedName))
    {
    $UserLogonName = $ADUser.distinguishedName
    Send-MailMessage -to email@domain.com -from no-reply@domain.com -SmtpServer 192.168.0.222 -title "User should be only in one group" -Body "Please Check if $UserLogonName do not exists in both groups"
    }
    else
    {
    if ($USgroup.member -contains $ADUser.distinguishedName)
    {
    $RegKey ="HKCU:\keyboard Layout\Preload"
    Set-ItemProperty -path $RegKey -name 1 -value 00000409
    }

    if ($UKgroup.member -contains $ADUser.distinguishedName)
    {
    $RegKey ="HKCU:\keyboard Layout\Preload"
    Set-ItemProperty -path $RegKey -name 1 -value 00000809
    }
    }
    http://proproit.com
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer