I hae the following powershell script I am working on... Basically I have utilized the Sybase ASE Client Assembly, Stored my connection info and dates vars . I can open the connection to the server and as I understand it run the query. However the issue I am having now is how to input the results of the query into a variable. What I am looking to do is run the query and store the value returned in a var called $results.
Now to the issue... Should I be using Invoke-Command to fire off the query or something else. I have seen a couple of different ways (for MS SQL) of doing it but not sure the best route.
#Add Sybase ASE Client Assembly
Add-Type -AssemblyName "Sybase.AdoNet2.AseClient, Version=2.157.701.0, Culture=neutral, PublicKeyToken=9x9x9x9x9x9x9x9x9x9e"
#database and Connection vars
$user = "user"
$pwd = "99999999"
$db = "Reporting"
$beginDate = (Get-Date).AddDays(-31)
$endDate = (Get-Date).AddDays(-2)
$WebUsageQuery="select count( * ) from Reporting..WebUsage w where w.LogDate between '$beginDate' and '$endDate'"
#Create Connection String
$SybConn = New-Object Sybase.Data.AseClient.AseConnection
$SybConn.ConnectionString = "Data Source='sybserverA';Port=5800;Database='$db';UID='$user';PWD='$pwd';"
$sybCmd = New-Object Sybase.Data.AseClient.AseDataAdapter
$sybCmd.SelectCommand = "$WebUsageQuery"
$sybCmd.SelectCommand.Connection = $SybConn
Write-Host $sybCmd and $SybConn
$sybAdapter = New-Object Sybase.Data.AseClient.AseDataAdapter
$sybAdapter.SelectCommand = "$sybCmd"
$DataSet = New-Object Sybase.Data.AseClient.AseDataAdapter