User Last name need change to UPPERCASE for all users

Hi guys,

I have a requirement to change all my AD users last name should change to UPPERCASE letters

I have more than 1000 users so i can’t change one by one manually.

I dont want to change logon name.It should be same like before.

i want to change only surname to uppercase.

Please let me know is there any script or any alternative to get this done.

The reason behind this is the admin who worked before me did not followed the proper process while creating.

So i want to changes to done on only particular OU not all.

I have some services accounts in other OU’s. I dont want to touch them.

Please suggest.

Thank you

Possible, If you have not tried anything so far for this, would suggest you to start putting up some code with the help of the help documentation of Get-ADUser and Set-ADUser cmdlets, may be help doc for Foreach-Object as well to start with. Folks here will help you when you get stuck.

[quote quote=197579]Possible, If you have not tried anything so far for this, would suggest you to start putting up some code with the help of the help documentation of Get-ADUser and Set-ADUser cmdlets, may be help doc for Foreach-Object as well to start with. Folks here will help you when you get stuck.

[/quote]

yes i tried below script but its throwing some kind of error

$targetUsers = Get-ADuser -SearchBase 'OU=india,DC=study,DC=com'
$targetUsers | foreach-object {
set-aduser $_ -Surname $_.surname.toupper()
}

error : cmdlet Get-ADUser at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
Filter:

When you say uppercase, what exactly do mean? Normally, you want to name in Title Case, you see:

The issue with Title Case is normally names with prefixes like McDonald:

$names = 'smith','mcdonald','decost', 'de cost'
foreach ($name in $names) {
    ((Get-Culture).TextInfo).ToTitleCase($name)
}

Output:

Smith
Mcdonald
Decost
De Cost

If you want all characters to Uppercase, while this is easy, I would not recommend it as Active Directory feeds many other business systems, signatures, etc. and it appears like someone is screaming your name in all of these systems. I usually have to fix applicants that use all caps on everything in Applicant Tracking Systems when they apply for a job before they are placed into HRM systems that feed into Active Directory. Start by collecting all of the names with Get-ADUser and if all users in scope are under an OU use the -SearchBase parameter and add -Properties SurName.

$users = Get-ADUser -Filter * -Properties SurName

Once you have the names, then apply the code to do the text transformation to validate and then you can use Set-ADUser to update the users.

[quote quote=197585]When you say uppercase, what exactly do mean? Normally, you want to name in Title Case, you see:

#PSTip How to convert words to Title Case
<iframe class="wp-embedded-content" title="" src="https://www.powershellmagazine.com/2013/07/24/pstip-how-to-convert-words-to-title-case/embed/#?secret=JDPiFooVgr" width="600" height="307" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" sandbox="allow-scripts" data-secret="JDPiFooVgr" data-mce-fragment="1"></iframe>

The issue with Title Case is normally names with prefixes like McDonald:

PowerShell
5 lines
<textarea class="ace_text-input" style="opacity: 0; height: 18px; width: 6.59781px; left: 44px; top: 0px;" spellcheck="false" wrap="off"></textarea>
1
2
3
4
5
$names = 'smith','mcdonald','decost', 'de cost'
foreach ($name in $names) {
((Get-Culture).TextInfo).ToTitleCase($name)
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Output:
PowerShell
5 lines
<textarea class="ace_text-input" style="opacity: 0; height: 18px; width: 6.59781px; left: 44px; top: 0px;" spellcheck="false" wrap="off"></textarea>
1
2
3
4
5
Smith
Mcdonald
Decost
De Cost
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
If you want all characters to Uppercase, while this is easy, I would not recommend it as Active Directory feeds many other business systems, signatures, etc. and it appears like someone is screaming your name in all of these systems. I usually have to fix applicants that use all caps on everything in Applicant Tracking Systems when they apply for a job before they are placed into HRM systems that feed into Active Directory. Start by collecting all of the names with Get-ADUser and if all users in scope are under an OU use the -SearchBase parameter and add -Properties SurName.
<textarea class="ace_text-input" style="opacity: 0; height: 18px; width: 6.59781px; left: 44px; top: 0px;" spellcheck="false" wrap="off"></textarea>
1
2
$users = Get-ADUser -Filter * -Properties SurName
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Once you have the names, then apply the code to do the text transformation to validate and then you can use Set-ADUser to update the users.

[/quote]
Hello Rob,

# Retrieve the Surname property (the sn attribute) of all users in the specified OU.
$Users = Get-ADUser -SearchBase "ou=Sales,ou=West,dc=domain,dc=com" -Filter {Surname -Like "*"} | Select DistinguishedName, Surname

ForEach ($User In $Users)
{
    $DN = $User.DistinguishedName
    $Name = $User.Surname

    # Desired case.
    $NewName = $Name.ToUpper() }

this above script worked for me it changed to all my surnames to uppercase but only thing is in DISPLAY NAME its still showing small case
hhow can i change that ?

 

 

$User.DisplayName ???