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
Post a Comment