Solved

C# equivalent of powershell format-custom ?

Posted on 2013-10-25
4
429 Views
Last Modified: 2013-11-16
Hi,

Is there an equivalent of the format-custom command. So the format looks very much like the original class / object in the source code.

I would like to use this for WMI objects but would hope it can be used for other objects as we'll.

thanks,

Ward
0
Comment
Question by:whorsfall
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
I don't believe that there is an equivalent, but where are you trying to use this?  In other words, what is the "bigger picture"?
0
 

Author Comment

by:whorsfall
Comment Utility
Hi,

Thanks for your response. Basically I am trying to output a WMI object
to a textbox for a UI I am writing and I like the quick way it formats all
the output.

Saves me writing a number of lines of code - to format the output.

The thinking I had was that since powershell is tied closely to .NET
I thought there might be a method call to do it.

Thanks,

Ward.
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Powershell may or may not use .NET components, so it is difficult to know for specific commands.  It would be an interesting challenge to try to find something.  I doubt, though, that there is anything to find.
0
 
LVL 42

Accepted Solution

by:
Rob Jurd, EE MVE earned 500 total points
Comment Utility
Yeah I can't see how you could do it either.  The formatting would be internal to powershell and it would basically format the data based on parameters you specify.  
It may take you just as long to code a generic class to format output based on a WMI input object than it would to trawl the web and testing sample code to get something you want.
You could always utilize powershell from your app but I see that as counter-productive.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now