I am using PowerShell cmdlet viz. Get-SPUser through C# program as follows
**Get-SPUSer** -web <siteCollection> | **format-table** Name,LoginName....
After I invoke this command it gives me ouptut in form of Collection< PSObject >
Now I want to traverse this collection of PSObject to get the actual records i.e. users with values of properties mentioned in command.
I want to use format-table instead of select-object. How to parse collection of PSObject to fetch property=value of user using C# ?
There is no other way but to use Out-String cmdlet using pipe which provides output in flat string format. Command is as follows
Get-SPUSer -web SiteCollection | format-list -property prop1, prop2 .. | Out-String
After removing newline/carriage returns and splitting techniques with string, I am able to get expected output. This is very crud way of achieving it but I have no choice. If select-object command has provided good performance then I would have go for it for sure.