Read each record in an Access Database using PowerShell

I have a fix database that I need to read each record and compare it to an issue. I'm having some issues just reading each record in the specific table, when i run the below code i just get the first entry over and over again. If somone could point me in the correct direction on how to read each record it would really help me out.

$adOpenStatic = 3
$adLockOptimistic = 3
$objConnection = New-Object -com "ADODB.Connection"
$objRecordSet = New-Object -com "ADODB.Recordset"
$objConnection.Open("Provider = Microsoft.ACE.OLEDB.12.0; Data Source = C:\temp\Fix.mdb")
$objRecordset.Open("Select * From Fix_Information", $objConnection, $adOpenStatic, $adLockOptimistic) 
$i = 0
do {
	$objRecordSet.Fields.Item("FixName").Value
	$objRecordSet.MoveNext | Out-Null
	$i++
}
while ($i -le $objRecordSet.RecordCount)
$objRecordSet.Close()
$objConnection.Close()

January 11th, 2014 5:29am

I haven't tested this, but it looks like you're just missing the parentheses after the MoveNext method name:

$objRecordSet.MoveNext() | Out-Null

  • Marked as answer by Zach Shupp Saturday, January 11, 2014 2:45 AM
Free Windows Admin Tool Kit Click here and download it now
January 11th, 2014 5:36am

you are right. I cant believe it was something that simple.

January 11th, 2014 5:45am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics