header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

We have a new sponsor!  Introducting Pragma Systems.  See the home page for details.

Set Keyboard Layout based on Group Membership
Last Post 11 Aug 2010 03:33 PM by stakanoff. 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:2
Avatar

--
26 Jul 2010 03:56 PM  
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




stakanoffUser is Offline
New Member
New Member
Posts:15
Avatar

--
11 Aug 2010 03:33 PM  
#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.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 footer
footer