Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# equivalent of powershell format-custom ?

Posted on 2013-10-25
4
Medium Priority
?
448 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39602664
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
 
LVL 1

Author Comment

by:whorsfall
ID: 39603415
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
ID: 39603836
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 43

Accepted Solution

by:
Rob earned 2000 total points
ID: 39605228
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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
On Beyond Tools A conversation I recently had with the DevOps manager of a major online retailer really made me think about DevOps monitoring tools (https://www.onpage.com/devops-incident-management-tool/). The manager and I discussed how sever…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

618 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