Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expand output > write to text file 1

Status
Not open for further replies.

monsterjta

IS-IT--Management
Sep 12, 2005
702
US
TIA,

This command

Code:
get-service | where-object {$_.name -match ("clr")}

produces this output:

Code:
Status   Name               DisplayName
------   ----               -----------
Running  clr_optimizatio... Microsoft .NET Framework NGEN v2.0....

I need it to produce the full, expanded name and displayname properties and write to a text file. Anybody know how?
 
Maybe like this..

Code:
get-service | where-object {$_.name -match ("clr")} | Format-Table -auto | Out-File "C:\temp\service.txt"


--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Thanks dm4ever. This is closer than what I had, but still not the result I need.

Code:
Status  Name                           DisplayName                             
------  ----                           -----------                             
Stopped clr_optimization_v2.0.50727_32 Microsoft .NET Framework NGEN v2.0.50...

This gives me a full, expanded name field. But still the DisplayName field is not expanded to show the full string.

DisplayName should read:
Code:
Microsoft .NET Framework NGEN v2.0.50727_X86

I'll play with this more, but any further examples?
 
That's odd...I tried it on two different machines and it displayed properly.

What if you tried adding -wrap to the Format-Table?

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
That's funny...I was just taking a look at -wrap. However, it places the text on the next line in the text file. That's makes it kinda tricky to parse.
 
You know...

Code:
format-list

will work just fine for my task. Thanks for your help.
 
BTW - This is what I ended up with. This is certainly an easily parsable format.

Code:
get-service | select-object name,displayname | where-object{$_.name -match ("clr")} | Format-list | out-file c:\service.txt

Just thought I'd follow up in case anyone else could use it.
 
List is good, but if you want to keep the table format and don't want the ellipses (...) you need to wrap the cell data. -autoSize only removes whitespace, so depending on your console size it may still truncate the info in the last column.
Try:
Code:
get-service | where-object {$_.name -match ("clr")} | Format-Table -auto -wrap | Out-File "C:\temp\service.txt"
-or-
Code:
get-service | where-object {$_.name -match ("clr")} | Format-Table -wrap | Out-File "C:\temp\service.txt"

The Out-File cmdlet only outputs what's on screen, the wrap parameter will make sure your results are not truncated...

Jesse Hamrick
 
You can use fl instead of format list

Code:
Get-ClientAccessServer | fl

Pat Richard, MCSE MCSA:Messaging CNA
Microsoft Exchange MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top