powershell: using convertfrom-csv
a friend of mine pointed out this really cool cmdlet called convertfrom-csv today. using it, you can immediately create a PSCustomObject. pretty cool! as a practical example, you can dump out repadmin and use the object to work with data any way you see fit.
[96] {D:\temp} > $foo = convertfrom-csv @(repadmin /showrepl * /csv)
[96] {D:\temp} > $foo | gmTypeName: System.Management.Automation.PSCustomObject
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Destination DC NoteProperty System.String Destination DC=myDC
Destination DC Site NoteProperty System.String Destination DC Site=mySite
Last Failure Status NoteProperty System.String Last Failure Status=0
Last Failure Time NoteProperty System.String Last Failure Time=0
Last Success Time NoteProperty System.String Last Success Time=2010-12-07 14:21:39
Naming Context NoteProperty System.String Naming Context=DC=myDomain,DC=com
Number of Failures NoteProperty System.String Number of Failures=0
showrepl_COLUMNS NoteProperty System.String showrepl_COLUMNS=showrepl_INFO
Source DC NoteProperty System.String Source DC=myDC2
Source DC Site NoteProperty System.String Source DC Site=mySite
Transport Type NoteProperty System.String Transport Type=RPC
Comments
Post a Comment