When I run this script the result does not get inserted into the database only the command I used to get the result.
If I simply output the variables $Computername and $username to the screen they output correctly
$Computername = 'get-wmiobject -query "select csname from win32_operatingsystem" | select-object csname | ft -hide'
$username = 'Get-Childitem env:username |select value | ft -hide'
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlInsert = @"
insert into info (computername,username)
Values ('$computername','$username')
"@
$Connection.open()
$SqlCmd.CommandText = $SqlInsert
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$SqlCmd.Connection = $Connection
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$Connection.Close()
Any Ideas as to how to insert only the variables rather than the commands?