How to automatically fix Orphaned Users with PowerShell and SQLCMD
The "(lots of dashes -----------------)" you talk about are a result of the output from sqlcmd.  Instead of using SELECT in your script, you likely want to use PRINT with a cursor.  SELECT will generate a resultset that sqlcmd will print to the screen along with header info.  The dashes are part of this header info.  

The T-SQL won't work for logins/users that have spaces in their names, or other special characters such as dashes, etc.  To make it work correctly for those users/logins, you need to wrap the name in square brackets, using QUOTENAME().

Something like this:

$dbname = "test"
$InstanceTarget = "CP708-D377\MV2012"

$FixOrphansSQL=@"
SET NOCOUNT ON;
DECLARE @cmd NVARCHAR(MAX);
SET @cmd = '';
DECLARE cur CURSOR LOCAL FORWARD_ONLY STATIC
FOR
SELECT FixUsersCmd = 'ALTER USER ' + QUOTENAME(dp.name) + ' 
    WITH LOGIN = ' + QUOTENAME(sp.name) + ';'
FROM sys.database_principals dp
    INNER JOIN sys.server_principals sp ON dp.name = sp.name AND dp.sid &lt;&gt; sp.sid
    AND dp.type_desc = 'SQL_USER';
OPEN cur;
FETCH NEXT FROM cur INTO @cmd;
WHILE @@FETCH_STATUS = 0
BEGIN
    PRINT @cmd;
    FETCH NEXT FROM cur INTO @cmd;
END
CLOSE cur;
DEALLOCATE cur;
"@
$RepairOrphansSQL = sqlcmd -S $InstanceTarget -Q $FixOrphansSQL -d $dbname
echo $RepairOrphansSQL
if ($RepairOrphansSQL.Length -gt 0) {
    sqlcmd -S $InstanceTarget -Q $RepairOrphansSQL -d $dbname
}


The above code checks if $RepairOrphansSQL actually contains any commands before running it; if the variable is empty, sqlcmd is not called.