Get-FormatData
Published: February 29, 2012
Updated: August 15, 2012
Applies To: Windows PowerShell 2.0, Windows PowerShell 3.0
Get-FormatData
Syntax
Parameter Set: Default Get-FormatData [[-TypeName] <String[]> ] [ <CommonParameters>]
Detailed Description
The Get-FormatData cmdlet gets the formatting data in the current session.
The formatting data in the session includes formatting data from Format.ps1xml formatting files (such as those in the $pshome directory), formatting data for modules that you import into the session, and formatting data for commands that you import into your session by using the Import-PSSession cmdlet.
You can use this cmdlet to examine the formatting data. Then, you can use the Export-FormatData cmdlet to serialize the objects (convert them to XML) and save them in Format.ps1xml files.
For more information about formatting files in Windows PowerShell, see about_Format.ps1xml.
Parameters
-TypeName<String[]>
Gets only the formatting data with the specified type names. Enter the type names. Wildcards are permitted.
|
Aliases |
none |
|
Required? |
false |
|
Position? |
1 |
|
Default Value |
none |
|
Accept Pipeline Input? |
false |
|
Accept Wildcard Characters? |
true |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/p/?LinkID=113216).
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
-
None
You cannot pipe input to this cmdlet.
Outputs
The output type is the type of the objects that the cmdlet emits.
- System.Management.Automation.ExtendedTypeDefinition
Examples
-------------------------- EXAMPLE 1 --------------------------
This command gets all the formatting data in the session.
PS C:\> get-formatdata
-------------------------- EXAMPLE 2 --------------------------
This command gets the formatting data items whose names begin with "Microsoft.Wsman".
PS C:\> get-formatdata -typename Microsoft.Wsman*
-------------------------- EXAMPLE 3 --------------------------
This example shows how to get a formatting data object and examine its properties.
PS C:\> $f = get-formatdata -typename helpinfoshortPS C:\>$fTypeName FormatViewDefinition-------- --------------------HelpInfoShort {help , TableControl}PS C:\>$f.FormatViewDefinition[0].controlHeaders Rows------- ----{System.Management.Automation.TableControlColumnHeader, System.Manageme... {System.Management.Automation.TableControlRow}PS C:\>$f.FormatViewDefinition[0].control.headersLabel Alignment Width----- --------- -----Name Left 33Category Left 9Undefined 0
-------------------------- EXAMPLE 4 --------------------------
This example shows how to use Get-FormatData and Export-FormatData to export the formatting data that is added by a module.
The first four commands use the Get-FormatData, Import-Module, and Compare-Object cmdlets to identify the format type that the BitsTransfer module adds to the session.
The fifth command uses the Get-FormatData cmdlet to get the format type that the BitsTransfer module adds. It uses a pipeline operator (|) to send the format type object to the Export-FormatData cmdlet, which converts it back to XML and saves it in the specified format.ps1xml file.
The final command shows an excerpt of the format.ps1xml file content.
PS C:\> $a = get-formatdataPS C:\>import-module bitstransferPS C:\>$b = get-formatdataPS C:\>compare-object $a $bInputObject SideIndicator----------- -------------Microsoft.BackgroundIntelligentTransfer.Management.BitsJob =>PS C:\>get-formatdata *bits* | export-formatdata -filepath c:\test\bits.format.ps1xmlPS C:\>get-content c:\test\bits.format.ps1xml<?xml version="1.0" encoding="utf-8"?><Configuration><ViewDefinitions><View><Name>Microsoft.BackgroundIntelligentTransfer.Management.BitsJob</Name>...
Related topics