Trailing spaces and hard returns

When running the following

$RAW = Get-ciminstance -classname win32_share | select path  

and then pass the results into a foreach such as

foreach ($Share in $Raw)
{
 Get-Acl $share   
}

I get an error such as Cannot find drive.

After a bunch of banging my head and testing the results individually, I discovered that there were trailing spaces and hard returns in the output that were making the variable invalid.

I fixed the issue by the following

 $RAW = Get-ciminstance -classname win32_share | select path | ForEach-Object {$_.path}
foreach ($Share in $Raw)
{
 Get-Acl $share   
}

Is their any way to know that the output contains trailing spaces? I did not see the issue until I sent the results to a text file and saw the carriage returns and the then while clicking around noticed that there were trailing spaces as well.

I suppose that I can add the Foreach-Object {$_. } but i was wondering if there were any other ways to address this issue.

In your select cmdlet, use -expandproperty.

@ Bob Thank you. I like the easy answers

Get-ciminstance -classname win32_share | select path -ExpandProperty path

It worked like a charm

Desired result

$RAW = Get-ciminstance -classname win32_share | select path -ExpandProperty path
foreach ($Share in $Raw)
{
 $Permissions = Get-Acl $share
 $Permissions.AccessToString   
}