Hello, can someone please help me with the following (I had a similar thread but I started a new one for clarify)
I want to find an alternative to using Where-Object in a pipeline. I have two large CSV files (where some of the fields are the same and some are different). I have a forach loop at the moment and where object but it is too slow.
I found the following function which takes a CSV and converts it to a DataTable
e.g.
$D = Out-DateTable -inputObject ( Import-csv c:\data\abc.csv )
if I then look at get-member for $D
$D | get-member
Name MemberType Definition
AcceptChanges Method void AcceptChanges()
BeginEdit Method void BeginEdit()
CancelEdit Method void CancelEdit()
ClearErrors Method void ClearErrors()
Delete Method void Delete()
EndEdit Method void EndEdit()
Equals Method bool Equals(System.Object obj)
GetChildRows Method System.Data.DataRow GetChildRows(string relationName), System.Data.DataRow GetChildRows(stringā¦
GetColumnError Method string GetColumnError(int columnIndex), string GetColumnError(string columnName), string GetColumnā¦
GetColumnsInError Method System.Data.DataColumn GetColumnsInError()
GetHashCode Method int GetHashCode()
GetParentRow Method System.Data.DataRow GetParentRow(string relationName), System.Data.DataRow GetParentRow(string relā¦
GetParentRows Method System.Data.DataRow GetParentRows(string relationName), System.Data.DataRow GetParentRows(striā¦
GetType Method type GetType()
HasVersion Method bool HasVersion(System.Data.DataRowVersion version)
IsNull Method bool IsNull(int columnIndex), bool IsNull(string columnName), bool IsNull(System.Data.DataColumn cā¦
RejectChanges Method void RejectChanges()
SetAdded Method void SetAdded()
SetColumnError Method void SetColumnError(int columnIndex, string error), void SetColumnError(string columnName, string ā¦
SetModified Method void SetModified()
SetParentRow Method void SetParentRow(System.Data.DataRow parentRow), void SetParentRow(System.Data.DataRow parentRow,ā¦
ToString Method string ToString()
Item ParameterizedProperty System.Object Item(int columnIndex) {get;set;}, System.Object Item(string columnName) {get;set;}, ā¦
AccountExpires Property string AccountExpires {get;set;}
Description Property string Description {get;set;}
DisplayName Property string DisplayName {get;set;}
DistinguishedName Property string DistinguishedName {get;set;}
Domain Property string Domain {get;set;}
Enabled Property string Enabled {get;set;}
LastLogonDate Property string LastLogonDate {get;set;}
PasswordLastSet Property string PasswordLastSet {get;set;}
PasswordNeverExpires Property string PasswordNeverExpires {get;set;}
PasswordNotRequired Property string PasswordNotRequired {get;set;}
sAMAccountName Property string sAMAccountName {get;set;}
UserAccountControl Property string UserAccountControl {get;set;}
WhenChanged Property string WhenChanged {get;set;}
WhenCreated Property string WhenCreated {get;set;}
The properties at the end are the original headings from my CSV files e.g. AccountExpires etc. (see below)
I want to find a record ādirectlyā for example where the property sAMAccountName is equal to Fred
I could do this $D | where-object {$_.sAMAccountName -eq āFredā}
however this is not direct and therefore slow when you have to do over and over for each record, I want to find the record by āindexingā as it where to go straight to the record I want
I thought the GetChildRows method may help but cannot figure it out
Can someone please assist, thanks very much in advance ![]()