public/Format-DisplayNames.ps1

function Format-DisplayNames {

    [cmdletbinding(SupportsShouldProcess=$True)]

    param (

    )

    # get users in a certain OU
    $OU = Select-ADOrganizationalUnit -HideNewOUFeature | Select-Object DistinguishedName -ExpandProperty DistinguishedName
    $Users = Get-ADUser -Filter * -SearchBase $OU

    # loop through all users found
    foreach($U in $Users){

        # assign variables
        $firstname = $U.givenname
        $surname = $U.surname
        $olddisplayname =$U.name
        
        # reassign variables with correct capitalization
        $firstname = $firstname.substring(0,1).ToUpper()

        $surname = $surname.substring(0,1).ToUpper()+$surname.substring(1).ToLower()

        # create the correct displayname
        $newdisplayname = $firstname + " $surname"

        # perform the rename action
        Set-ADUser -Identity $U -DisplayName $newdisplayname
        Rename-ADObject -Identity $U -NewName $newdisplayname

        Write-Host "Renamed $olddisplayname to $newdisplayname" -ForegroundColor Green

    }
}