I currently have the following script:
$SQLServer = "sqldev1"
$SQLDBName = "SPDEV_Printing"
$SqlQuery = "select * from PcBeheerPrinter WHERE PRT_name = 'bwpsc006'"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = $SQLServer; Database = $SQLDBName; Integrated Security = True"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$SqlConnection.Close()
clear
$DataSet.Tables[0]
which returns some console output like this:
PRT_PrintServerName : pcounter
PRT_Name : bwpsc006
PRT_PortNameFull : PCOUNT_bwpsc006
PRT_CAL_SerialNumber :
PRT_ACTIVE : 1
PRT_CAL_RespondToPing : 1
PRT_CAL_NamePinged : bwpsc006
PRT_CAL_FirstSeendate : 8/02/2017 20:55:13
PRT_CAL_LastSeendate : 4/12/2017 11:36:19
PRT_CAL_SNMPPossible : 1
PRT_CAL_Brand :
PRT_ShareName : bwpsc006
PRT_Comment :
PRT_Datatype : RAW
PRT_DriverName : Canon iR-ADV C5045/5051 PCL6
PRT_Location :
PRT_PrintProcessor :
PRT_Published : 0
PRT_Shared : 0
PRT_NumberOfMissedPings : 0
PRT_LastResponsedate : 4/12/2017 11:36:19
PRT_RenderingMode : CSR
My question is: How do I transfer some of these values into PS variables? I need the Name, SerialNumber and some others (these will do as example) to eventually transfer them to a SharePoint list. I'm still a beginner and can't figure it out through googling.
Thanks!
$Name = $DataSet.Tables[0].PRT_Name;$SerialNo = $DataSet.Tables[0].PRT_CAL_SerialNumberand so on!