Category Archives: Strings

Working with strings: bits and pieces

In the previous post I showed how to generate the parent OUs by splitting and rejoining a string. I used the operators –split and –join These were introduced in PowerShell v2.  In PowerShell v1 we had to use the split() … Continue reading

Posted in PowerShell V2, Strings | Leave a comment

Working with strings: I’m a substitute

PowerShell string substitution is a very neat trick PS (1) > $string = “World”PS (2) > “Hello $string”Hello World   We can substitute the value of the variable into the string. The catch – it only works with double quoted … Continue reading

Posted in PowerShell V2, Strings | Leave a comment

Working with strings: likes and dislikes

Lets start with a string $str = “abcdefghi” We often only have part of a string to work with so we end up using –like $str -like “abc*”$str -like “*abc*”$str -like “*def*”$str -like “*ghi”   these all return True   … Continue reading

Posted in PowerShell V2, Strings | Leave a comment

Working with Strings: Simple comparisons

Lets start with simple string matching as its a task that frequently comes along “aaa” -eq “aaa” “aaa” -ceq “aaa”   both return true.  What’s –ceq you ask? PowerShell by design is case insensitive so for most operations it treats … Continue reading

Posted in Strings | Leave a comment