I use the following to connect to SQL DB in VC 2.5, but it does not work on v4. The VC 2.5 is also running SQL 2005 32 bit and v4 is running SQL 2008 64 bit.
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server=$SQLSERVER;Database=$DATABASE;Integrated Security=True"
Exception calling "Fill" with "1" argument(s): "Timeout expired. The timeout p
eriod elapsed prior to completion of the operation or the server is not respond
ing."
At C:\DOCUME1\ADMINI1\LOCALS~1\Temp\1\ec8bf244-8877-46aa-ac5c-1a82ae6775bf.ps
1:19 char:17
+ $SqlAdapter.Fill( <<<< $DataSet)
Exception calling "Fill" with "1" argument(s): "Timeout expired. The timeout p
eriod elapsed prior to completion of the operation or the server is not respond
ing."
At C:\DOCUME1\ADMINI1\LOCALS~1\Temp\1\ec8bf244-8877-46aa-ac5c-1a82ae6775bf.ps
1:20 char:31
+ $v03created = $SqlAdapter.Fill( <<<< $DataSet)
Unable to index into an object of type System.Data.DataTableCollection.
At C:\DOCUME1\ADMINI1\LOCALS~1\Temp\1\ec8bf244-8877-46aa-ac5c-1a82ae6775bf.ps
1:22 char:17
+ $DataSet.Tables[0 <<<< ] | Export-Csv "C:\VMware_Healthcheck\SQL-Create-Delet
ed-VMs\vcell03_created.csv" -noTypeInformation