Skip to Main Content
Windows Server 2008: The Definitive Guide
book

Windows Server 2008: The Definitive Guide

by Jonathan Hassell
March 2008
Beginner to intermediate content levelBeginner to intermediate
494 pages
13h 4m
English
O'Reilly Media, Inc.
Content preview from Windows Server 2008: The Definitive Guide

Formatting Basics

PowerShell was designed for use by administrators as opposed to programmers, unlike VBScript. PowerShell knows how to format the objects produced by cmdlets or to display variable and other data typed at the PowerShell prompt. As we have seen in this chapter thus far, you can simply enter a cmdlet or variable at the PowerShell prompt, and get nicely formatted output. You can also use four additional cmdlets, Format-Table, Format-List, Format-Wide, and Format-Custom to create different forms of output.

PowerShell provides you with a number of options for formatting. In most cases, you can just accept PowerShell's built-in formatting. Or, if you are so inclined, you can delve deeper into .NET for richer formatting features.

To illustrate PowerShell formatting, here is a simple command that uses a Get-WMI object to retrieve information about the memory devices in a computer:

PSH [D:\foo]: Get-WMIObject -Class win32_memorydevice _ _GENUS : 2 _ _CLASS : Win32_MemoryDevice _ _SUPERCLASS : Win32_SMBIOSMemory _ _DYNASTY : CIM_ManagedSystemElement _ _RELPATH : Win32_MemoryDevice.DeviceID="Memory Device 0" _ _PROPERTY_COUNT : 39 _ _SERVER : XP21 _ _NAMESPACE : root\cimv2 _ _PATH : \\XP21\root\cimv2:Win32_MemoryDevice.DeviceID="Memory Device 0" Access : AdditionalErrorData : Availability : BlockSize : Caption : Memory Device ConfigManagerErrorCode : ConfigManagerUserConfig : CorrectableError : CreationClassName : Win32_MemoryDevice Description : Memory Device DeviceID : Memory ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Complete Guide to Windows Server 2008

The Complete Guide to Windows Server 2008

John Savill

Publisher Resources

ISBN: 9780596514112Errata Page