Here's what I did to test and this works:
--Create test table with identity column in SQL Server Management Studio
CREATE TABLE [dbo].[test](
[id] [int] IDENTITY(1,1) NOT NULL,
[c1] [nchar](10) NOT NULL
);
# Execute the following Powershell commands from Powershell
#My instance name is SQLEXPRESS an database name is dbutility
$conn = New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = "Server=$env:computername\SQLEXPRESS; Database=dbautility; Integrated Security=true"
$conn.Open()
$cmd = New-Object System.Data.SqlClient.SqlCommand
$cmd.CommandText = "INSERT INTO Test(c1) VALUES (@Name); SET @NewCompPKID = SCOPE_IDENTITY();"
$cmd.Connection = $conn
$Name = 'test'
$cmd.Parameters.AddWithValue("@Name", $Name)
$cmd.Parameters.Add("@NewCompPKID", [System.Data.SqlDbType]"Int").Direction = [System.Data.ParameterDirection]::Output
$cmd.ExecuteNonQuery()
$cmd.Parameters["@NewCompPKID"].Value
$conn.Close()