Register
: :
Login
Home
Forums
Blogs
Podcast
Directories
Scripts
Downloads
Community
User Group Support
Learning Resources
We have a new sponsor! Introducting
Pragma Systems
. See the home page for details.
Unanswered
Active Topics
Forums
Search
Members
Forums
>
Using PowerShell
>
Active Directory
Set Keyboard Layout based on Group Membership
Last Post 11 Aug 2010 03:33 PM by
stakanoff
. 1 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
dimepop
New Member
Posts:2
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
stakanoff
New Member
Posts:15
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.
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Using PowerShell
--General PowerShell
--Books, Tools, and Videos
--Exchange Server
--Active Directory
--System Center Family
--Non-Microsoft Products
--SharePoint
--SQL Server
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
Forums
>
Using PowerShell
>
Active Directory
Active Forums 4.1
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008