String issue


i know i'm doing !!!

$a = get-process | group processname | ft name,count -auto -hidetableheaders | out-string -stream |? {$_ -match "\s"}

 

$b = $a + "test"

$c = "test"+ $a

$b return want

$c is completely messed up, , seems stripe newline

 

why ? how ? fix ?

is type issue, how know $a variable type ?

 

thank you

 

 

i think (and can explain better) happening this...

gm -i $a
typename: system.object[]
...

$a | gm
typename: system.string
..

so $a array of strings. when $a + test array addition , add string in array.. kind of $a.add("test")

but when "test" + $a, says hey, have string , want concatinate it, take $a , makes it’s string, $a.tostring()

so, im not sure want fix, use $test first.. or make "test" array so

$c = @("test") + $a



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Can no longer user MS Update - Files required to use Microsoft Update are no longer registered

How do a find data in one file, search for it in another file and if not found, write a custom message to another file