I have a problem with a quick function I wrote for splitting Sharepoint specific ids ({id};#{name}):
function GetOnlyValue {
param(
[string] $fullValue
)
if(![string]::IsNullOrEmpty($fullValue))
{
# On regarde si on a la valeur
if($fullValue -Like "*;#*")
{
$array = $fullValue -split ";#", 2, "simplematch"
return $array[-1]
}
}
return $fullValue
}
But this function does half the job because, for instance, when I pass a value formated like that : myId;#myName the function return me this value: "#myName" instead of "myName".
Thanks for your help !
06/02/2016 EDIT: This function is included in a module that I import in a script. I use it in correlation with a Sharepoint 2013 site, browsing each SPListItem of a SPList:
$formation = GetOnlyValue -fullValue $spItem["Formation"]
'myId;#myName' -split ';#',2,'simplematch'works as expected.$spItem["Formation"]and ensure its a stringGetOnlyValue -fullValue ([string]$item["Formation"])Thanks to all for your help !