Bulk change preferredLanguage on-premise Active Directory

%3CLINGO-SUB%20id%3D%22lingo-sub-2401012%22%20slang%3D%22en-US%22%3EBulk%20change%20preferredLanguage%20on-premise%20Active%20Directory%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2401012%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20need%20to%20change%26nbsp%3B%3CSTRONG%3EpreferredLanguage%3C%2FSTRONG%3E%20(Attribute%20Editor)%20on%20our%20on-premise%20AD%20for%20all%20users%20to%26nbsp%3B%3CSTRONG%3Enl-NL%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20searching%20Google%20for%20over%20one%20hour%2C%20but%20only%20find%20a%20lot%20of%20information%20related%20to%20O365%20(Azure%20AD).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20should%20start%20with%20the%20GET-command%20below%20to%20'find'%20all%20users.%3C%2FP%3E%3CP%3E%3CEM%3EGet-ADOrganizationalUnit%20-Filter%20%7B%20name%20-like%20'*users*'%20%7D%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20script%20should%20i%20use%20to%20change%20attribute%26nbsp%3BpreferredLanguage%26nbsp%3Bto%26nbsp%3Bnl-NL%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlready%20big%20thanks%20for%20your%20support!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2401012%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2425527%22%20slang%3D%22en-US%22%3ERe%3A%20Bulk%20change%20preferredLanguage%20on-premise%20Active%20Directory%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2425527%22%20slang%3D%22en-US%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1067425%22%20target%3D%22_blank%22%3E%40TDJNL2006%3C%2FA%3E%2C%3C%2FP%3E%3CP%3ETo%20change%20attribute%20for%20Active%20Directory%20objects%20you%20should%20use%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Factivedirectory%2Fset-adobject%3Fview%3Dwindowsserver2019-ps%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESet-ADObject%3C%2FA%3E%20cmdlet.%3C%2FP%3E%3CP%3EOnce%20you%20get%20users%20then%20loop%20trough%20the%20collection%20and%20set%20required%20attribute%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24AllUsers%3DGet-ADUser%20-Filter%20*%0A%0Aforeach%20(%24u%20in%20%24AllUsers)%7B%0A%20%20%20%20Set-ADObject%20-Identity%20%24u.DistinguishedName%20-replace%20%40%7BpreferredLanguage%3D%22nl-NL%22%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EHope%20that%20helps.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

Hi all,

 

I need to change preferredLanguage (Attribute Editor) on our on-premise AD for all users to nl-NL.

 

I'm searching Google for over one hour, but only find a lot of information related to O365 (Azure AD).

 

 

I should start with the GET-command below to 'find' all users.

Get-ADOrganizationalUnit -Filter { name -like '*users*' }

 

 

What script should i use to change attribute preferredLanguage to nl-NL?

 

Already big thanks for your support!

1 Reply

Hello @TDJNL2006,

To change attribute for Active Directory objects you should use Set-ADObject cmdlet.

Once you get users then loop trough the collection and set required attribute:

$AllUsers=Get-ADUser -Filter *

foreach ($u in $AllUsers){
    Set-ADObject -Identity $u.DistinguishedName -replace @{preferredLanguage="nl-NL"}
}

Hope that helps.