Not VB.NET, but I do SQL calls with PowerShell no problem. This is used in my 
OSD FrontEnd to pull printer info from SQL and MySQL. I did have to copy the 
.dll locally for MySQL.

SQL
   $sqlserver = "SERVER"
    $sqldb = "DB"
    $sqlquery = "
    SELECT  dbo.v_R_System.Name0, dbo.v_R_System.User_Name0, 
dbo.v_GS_PRINTER_DEVICE.Name0, dbo.v_GS_PRINTER_DEVICE.DeviceID0,
            dbo.v_GS_PRINTER_DEVICE.DriverName0, 
dbo.v_GS_PRINTER_DEVICE.PortName0
    FROM    dbo.v_R_System INNER JOIN
            dbo.v_GS_PRINTER_DEVICE ON dbo.v_R_System.ResourceID = 
dbo.v_GS_PRINTER_DEVICE.ResourceID
    where (PortName0 not like 'LPT%'
                     and dbo.v_GS_PRINTER_DEVICE.Name0 not like '%pdf%')
            and (dbo.v_R_System.Name0 = '$computer' or 
dbo.v_R_System.User_Name0 = '$user')"

    $connection_string = "server=$sqlserver;database=$sqldb;integrated 
security=true"

    $sqlConnection = new-object System.Data.SqlClient.SqlConnection 
$connection_string
    $sqlConnection.Open()

    $adapter = new-object data.sqlclient.sqldataadapter($sqlquery, 
$sqlConnection)

    $set = new-object data.dataset
    $adapter.fill($set) | out-null
    $global:table = new-object data.datatable
    $global:table = $set.tables[0]

MySQL
    $mysqlserver = "SERVER"
    $mysqldb = "printer_list"
    $mysqluser = "un"
    $mysqlpassword = 'pw'
    $mysqlconnectionstring = "Server=$mysqlserver; Database=$mysqldb; 
User=$mysqluser; Password=$mysqlpassword"

    $mysqlquery = "
    SELECT       Model,IP,Queue_DNS,Building,Floor,Printer_ID,Location
    FROM         printers
    WHERE ip = '$printerip' or queue_dns = '$printerip'"

    add-type -Path ".\MySql.Data.dll"

    $connection = New-Object MySql.Data.MySqlClient.MySqlConnection
    $connection.ConnectionString = $mysqlconnectionString
    $connection.Open()
    $command = New-Object MySql.Data.MySqlClient.MySqlCommand($mysqlquery, 
$connection)
    $dataAdapter = New-Object MySql.Data.MySqlClient.MySqlDataAdapter($command)
    $global:mysqltable = New-Object System.Data.DataTable
    $recordCount = $dataAdapter.Fill($mysqltable)


Daniel Ratliff

From: [email protected] [mailto:[email protected]] On 
Behalf Of Atkinson, Wade A
Sent: Tuesday, September 02, 2014 10:40 AM
To: [email protected]
Subject: [MDT-OSD] VB.Net Application accessing TS Variables

Has anyone been able to access / modify the TS Variables using a VB .NET 
application.  It's very simple with Visual Basic, but as we move to SCCM 2012 
we will also be moving to a 64bit boot environment.  My VB apps used to make 
SQL calls will no longer work, so I am attempting to migrate them to .NET.

Any examples would be appreciated.  I have tried to get the COM object to work 
with no luck.
Thanks,
Wade




Wade Atkinson, MCSE, Lead IT Engineer
IS Workplace Technology
_______________________________________________________________________________________________________________________________
CenturyLink | 600 New Century | New Century KS 66031
office 913 738 5766 | cell 913 744 5455


The information transmitted is intended only for the person or entity to which 
it is addressed
and may contain CONFIDENTIAL material.  If you receive this 
material/information in error,
please contact the sender and delete or destroy the material/information.

Reply via email to