Skip to content

Instantly share code, notes, and snippets.

@beargolightly
Created October 11, 2018 00:39
Show Gist options
  • Select an option

  • Save beargolightly/2a3ad4047351124e0413028c321064ad to your computer and use it in GitHub Desktop.

Select an option

Save beargolightly/2a3ad4047351124e0413028c321064ad to your computer and use it in GitHub Desktop.
extremely dirty Powershell script to read data from a free-tables DBF
# this is a quick and dirty proof-of-concept of reading our specific DBF files from Powershell
# WARNINGS:
# 1. you have to have the foxpro OLE DB 32-bit version installed
# 2. you have to run this w/ the 32-bit version of powershell
# 3. 'exclusive=no' may not be right for you
# 4. πŸ‘ DONT πŸ‘ USE πŸ‘ FOXPRO πŸ‘ ANYMORE πŸ‘
# I don't know what Powershell will do will all those emojis and I'm not going to find out
$ConnString = "Provider=vfpoledb;Data Source=h:\;Extended Properties=dBASE IV;exclusive=no"
$Conn = new-object System.Data.OleDb.OleDbConnection($ConnString)
$Conn.open()
$cmd = new-object System.Data.OleDb.OleDbCommand("select * from errorlog2 where day(date)=day(datetime()) and month(date)=month(datetime()) and year(date)=year(datetime())",$Conn)
$da = new-object System.Data.OleDb.OleDbDataAdapter($cmd)
$dt = new-object System.Data.dataTable
$da.fill($dt)
$dt|select date, message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment