Using Pester to Test PowerShell Code with Other Cultures

I recently published a blog article on unexpected case sensitivity in PowerShell. An example in that blog article uses the contains method which is indeed case sensitive. One of the workarounds that I demonstrated was to convert whatever the user entered to upper case using the ToUpper() method.

One of the reasons I like blogging is that many times there are things that I may not have considered and sometimes things that I wasn’t even aware of so in addition to sharing my knowledge with others, I often times learn in the process based on the feedback I receive about my blog articles and this was one of those times.

I received a response to my tweet about that blog article from @Oleschri on Twitter:


“You know that using conversions like .ToUpper() to do case insensitive comparisons can be problematic?”


No one knows everything so always be willing to listen to others. My response: “I haven’t had any problems with .ToUpper(), but if it can be problematic, I would like to hear more about that & see some examples”


“Sure. I present to you the The Turkey Test. Yeah, really, they call it that.


“I admin, nobody should expect i18n problems in service names. But I never give advice to use such workarounds for that reason.”

More info about i18n:

After reading the previously referenced “Turkey Test” blog article, I created a simple Test-ToUpper function in PowerShell to test with:

I created a Pester test to not only test using my culture, but also with the Turkish culture via the Use-Culture function that’s part of the PowerShellCookbook module (the PowerShell Cookbook and module was written by Lee Holmes):

The results show that using the ToUpper() method does indeed have the “Turkish I” problem as it’s referred to:


I’m sure you can see how simple it really is to test your code and make sure it works internationally and not just with your localization.


Give credit to others and thank them for their assistance. This will make them more likely to provide feedback to you and to others in the future. My response: “You’re right. It has the “Turkish I” problem. Thanks for the info. That gives me some additional tests to perform on my code.”


1 Comment

  1. Jaap Brasser

    Cool nice article, I like articles like this. I have been struggling to convince myself to invest some time with Pester and articles like this are useful to me as they show real world examples of how to apply Pester to solve a problem.


Leave a Reply

%d bloggers like this: