PowerShell strings have a split function that enables the simple splitting of a string into an array of strings based on a delimiter character.
The example below splits based on the space character and removes any entries that have no actual content.
$FullName = “John Savill ”
$Names = $FullName.Split(” “,[StringSplitOptions]’RemoveEmptyEntries’)
$Names would contain two entries: John and Savill. The trailing spaces were removed.