I just received a PowerShell question from a community member by direct message through Twitter… His question was: ”struggling to determine the length of a string with contains a numbers as value in PowerShell … any tips?”.
This is actually a very good question since this is something that is done quite a lot
And as I came to think about it, I’ve never written anything about that topic so here I am ![]()
Let’s take a string you’ve filled with a bunch of characters…
$string = 12345678
When you want to know the number of characters in this string, you can get this information with the following line:
$string | measure-object –character
But… that gives you a few column names and the number of characters…
![]()
so still too much information (I don’t want those column names, just the number of characters!). To just get the number of characters, use the following line:
$string | measure-object -character | select -expandproperty characters
Which in turn you can put in it’s own variable:
$characters = $string | measure-object -character | select -expandproperty characters
Just in case you’ve missed it: Somewhere last year I tweeded about a personal project I was working on at the time, Project Methos. This involved starting my own company which I found out later on was a lot more work than I anticipated
But nevertheless, as from the 1th of February 2012 I started my own company: Methos IT. ![]()
Now that’s up and running I decided to take on a new project… and named it Project Blue Lantern. The same as with Project Methos, I won’t tell what it involves… but maybe a little hint will slip by me on Twitter every once in a while ![]()

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Back
Void « Default
Life
Earth
Wind
Water
Fire
Light 