≡ Menu

PowerShell: How to change text to Title Case(first letter to upper case and remaining lower case)

We all know how to change a string to lower case or upper case. It is as good as invoking .Toupper() or .Tolower() methods of the string variable.

For example…

PS C:\> “TechiBee”.toupper()
TECHIBEE
PS C:\> “TechiBee”.tolower()
techibee
PS C:\>

But when it comes to changing to Title case where first letter of the word is in capital and remaining letter in world in lower case, people are using variety methods. Some people are using substring method to identify the first character to upper and remaining to lower case and then combining them to get the title case of original word/string.

Actually, It is not that hard. PowerShell has very powerfull features and you should be doing it with very easy procedures. Let us see how to do it.

PS C:\> (Get-Culture).textinfo.totitlecase(“TechiBee.com”.tolower())
Techibee.Com
PS C:\>

In the above example, I am using the ToTitleCase method that is available with Get-Culture cmdlet. All we need to do is pass the string as argument to this function to get it converted to title case. I passed “TechiBee.com” for demonstration and you can see the output. You might have noticed that “com” in “TechiBee.com” also got changed it to title case as this is also a different word in the given string. You might want to ask why we need to change it to lower case before performing the conversion. I too don’t have a answer for it but the thing is, if the given string/word has all capital letters, then this method is not changing the string to title case. Hence I used ToLower() method. You can see the below demonstration for clarity.

Hope this helps…

Comments on this entry are closed.

  • Pheromones That Attract Women July 29, 2013, 11:24 am

    I by no means had to put on maternity pants, that drink, is DISGUSTING, I didn’t have to pee also usually, just Genuinely negative, each morning, never ever did the elastic band thing, and i never experienced early morning sickness. I did not have the typical pregnancy, it was simpler, and so was labor. Only about four hrs of energetic labor.

  • teeth whitening tips for braces August 2, 2013, 12:15 am

    I want to thank these who posted lemon juice for lack of stomach
    acid I’ve suffered from a cough for years no doctor could give me any explanation after different tests.When i was on this sight i read the posts about lemon juice for lack of stomach acid and happen to be trying this ever because using PLJ it works like a miracle i have vertually no coughing and can sleep through the night without coughing thank you so a lot this treatment works for me I always check your sight now to keep healthful.

  • Jamie February 24, 2015, 10:07 am

    Thanks for the post, very helpful.

  • Shadock712 January 14, 2018, 5:34 am

    Just what was needed.
    Great !

  • ray December 23, 2019, 8:49 pm

    Thanks for the experience

  • Dread June 16, 2020, 12:56 pm

    Thanks for that! just what I needed.