Check scratch tapes from Powershell

maksbond

Newcomer
Joined
Nov 20, 2015
Messages
2
Reaction score
0
Points
0
Hi guys,

I have some problem with query:
" SELECT COUNT(*) FROM libvolumes WHERE MEDIATYPE='LTO-5' AND status='Scratch' "

When run that query from TSM console, it`s OK, and data that returns actual. But if I run that query from Powershell script via IBMDADB2 provider, data that return always the same, and not updated. As if the data is written to the cache.

Problem I have only with that query. Can you help me?

P.S. Sorry about my English :)
 
It looks like an issue with your Powershell script. Are you sure you are passing the select command properly to the TSM server?
 
My function:
"function DB2Query {
param ($query)
Process {
try {
$cn = new-object system.data.OleDb.OleDbConnection("Provider=IBMDADB2;Database=TSMDB1;Hostname=" + $DB2HOSTNAME + ";Protocol=TCPIP;Port=" + $DB2PORT + ";Uid=" + $DB2USERNAME + ";Pwd=" + $DB2PASSWORD + ";")
$ds = new-object "System.Data.DataSet" "dsEmployee"
$da = new-object "System.Data.OleDb.OleDbDataAdapter" ($query, $cn)
$da = $da.Fill($ds)
$result = new-object "System.Data.DataTable" "dtEmployee"
$result = $ds.Tables[0]
return $result
}
catch {
Write-EventLog -LogName "DB2" -Source "DB2Query" -EntryType "Error" -EventId 101 -Message ($Error[0].ToString() + "`n" + $query)
Break
}
}
}"

With this function I`m passing the select command like that:
"$q = "SELECT COUNT(*) FROM " + $DB2DBNAME + ".libvolumes WHERE MEDIATYPE='LTO-5' AND status='Scratch'"
$return = DB2Query($q)"
 
"$q = "SELECT COUNT(*) FROM " + $DB2DBNAME + ".libvolumes WHERE MEDIATYPE='LTO-5' AND status='Scratch'"

The select statement should this look like:

select count(*) from libvolumes where status='Scratch'
 
Back
Top