Important Notice: On February 29th, this community will be put into read-only mode. All existing posts will remain but customers will be unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Get-ODBCDsn PS Script

Wrote this script that works locally on my test system.

$Properties = @(
"Name"
"DsnType"
"Platform"
"DriverName"
)

Get-ODBCDsn | Select-Object $Properties

When run locally it returns:

Name DsnType Platform DriverName
---- ------- -------- ----------
MS Access Database User 32-bit Microsoft Access Driver (*.mdb, *.accdb)
Excel Files User 32-bit Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)
dBASE Files User Unknown Platform Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx)

I created a scanner with the script and ran against the test PC. The scanner runs successfully but returns no data. I ran the script against a larger set of systems and did get some results. Why would the script run locally and not return to PDQ?

Thanks.

1

Comments

2 comments
Date Votes
  • David,

    It works locally because it is returning all of your user's ODBC connections. The PDQ Inventory scan user doesn't have any user connections, so the scanner can only see the system ODBC connections. That is probably why it's only returning data for some of the computers and not all of them-- you only get data back if there is a system ODBC connection.

    I also re-wrote your scanner slightly to test in my environment but if yours works for you then there is no need to change it. I did filter to DsnType of "System" since that's all you will get anyway:

    #ODBC
    Get-ODBCDsn -DsnType System | ForEach-Object {
       [PSCustomObject]@{
          Name = $_.Name
          DsnType = $_.DsnType
          Platform= $_.Platform
          DriverName= $_.DriverName
       }
    }

    1
  • Makes Sense, Thanks. I need all this info so will look into registry searches.

    0

Please sign in to leave a comment.

Didn't find what you were looking for?

New post