I'm reading and parsing a CSV file. The VBS script below is so simple and works great in Win2k3. But no go in Windows 2008 - all because I can't find a Windows 2008 text driver. Can anyone give any hints on how to best convert this to Powershell? Or is there something simple I'm missing to make this work in Win2k8?
'==========================================================
dim objConnection, ObjRecordset, outFullName, outUserName, strOutFile, objFSO, objFile
'==================== OUTPUT SECTION ============================================
'set up the output stuff first
Const ForWriting = 2
Const OpenAsASCII = 0
Const CreateIfNotExist = True
' Specify output file
strOutFile = "C:\ExportUsers\ParsedUserNames.txt"
' Open the output file
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strOutFile, ForWriting, CreateIfNotExist, OpenAsASCII)
'=================== INPUT SECTION =================================================
'Set up the input stuff - prepare to read exportusernames.csv
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = "Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=."
objConnection.Open
'Create recordset and read in the input file
Set objRecordset = objConnection.Execute("SELECT * FROM C:\Exportusers\exportusernames.csv")
Do Until objRecordset.EOF
outFullName = objRecordset.Fields("name").Value
outUserName = objRecordset.Fields("sAMAccountName").Value
'===================== DO THE MAGIC ========================================
'Write the each line into the opened text file
objfile.writeline outFullName & "=" & outUserName
End If
objRecordset.MoveNext
Loop
objfile.close