Search code examples
powershellsharepoint-2010powershell-2.0

Split a string to multiple strings in powershell


I have strings like

$value = "1;#Mohapatra,Mrutyunjaya (ADM) 10;#Sumit Upadhyay(ADM) 11;#Naidu,Ishan(ADM)"

I want to retrieve

"Mohapatra,Mrutyunjaya (ADM)", "Sumit Upadhyay(ADM)", "Naidu,Ishan(ADM)" 

from $value.

I have tried $value.Split(";#")[0]. It is returning the first parameter only. But I want all the parameters


Solution

  • Just FYI, if you want to declare each as a variable you can say $a,$b,$c,$d = $Value -Split (";#") and each of $a, $b, $c and $d will retain those values.