I was prototyping using Invoke-Sqlcmd using the script at http://msdn.microsoft.com/en-us/library/ms188792.aspx
I was getting strange behavior with duplicate entries. I tested the script using sqlcmd.exe and had no issues.
I simplified the example to use one table with a check constraint and was able to reproduce the error.
In my steps to reproduce, if you remove the line inserting 4 you correctly get 1,2,3
The same error occurs if you pass the query by parameter
> Invoke-Sqlcmd -ServerInstance $Server -Database $Database -Query $Query
If you execute the query using sqlcmd.exe it works correctly
> & sqlcmd -S $Server -d $Database -i $TempFile