Replace this:
{(Split-path $_.directory -leaf)},last*
With this:
@{ n='Username'; e={ Split-path $_.directory -leaf } },last*
Then the property is named on the pipeline and you can then do:
<your script> | Select -Expand UserName
Explanation:
@{Name=$StringVaue; Expression=$ScriptBlock}
is how you can add Calculated Properties
to Select-Object
. Short Form @{n=$StringValue; e=$ScriptBlock}