Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

ConvertTo-Xml

Updated: August 9, 2015

ConvertTo-Xml

Creates an XML-based representation of an object.

Syntax

Parameter Set: Fragment
ConvertTo-Xml [[-Property] <System.Object[]> ] [-As <System.String> {Table | List} ] [-Fragment] [-InputObject <System.Management.Automation.PSObject> ] [-PostContent <System.String[]> ] [-PreContent <System.String[]> ] [ <CommonParameters>]

Parameter Set: Page
ConvertTo-Xml [[-Property] <System.Object[]> ] [[-Head] <System.String[]> ] [[-Title] <System.String> ] [[-Body] <System.String[]> ] [-As <System.String> {Table | List} ] [-CssUri <System.Uri> ] [-InputObject <System.Management.Automation.PSObject> ] [-PostContent <System.String[]> ] [-PreContent <System.String[]> ] [ <CommonParameters>]




Detailed Description

The ConvertTo-Xml cmdlet creates an XML-based representation of one or more Microsoft .NET Framework objects. To use this cmdlet, pipe one or more objects to the cmdlet, or use the InputObject parameter to specify the object.

When you pipe multiple objects to ConvertTo-XML or use the InputObject parameter to submit multiple objects, ConvertTo-XML returns a single XML document that includes representations of all of the objects.

This cmdlet is similar to Export-Clixml except that Export-Clixml stores the resulting XML in a file. ConvertTo-XML returns the XML, so you can continue to process it in Windows PowerShell.

Parameters

-As<System.String>

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Body<System.String[]>

Aliases

none

Required?

false

Position?

4

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-CssUri<System.Uri>

Aliases

cu,uri

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Fragment

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Head<System.String[]>

Aliases

none

Required?

false

Position?

2

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-InputObject<System.Management.Automation.PSObject>

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true(ByValue)

Accept Wildcard Characters?

false

-PostContent<System.String[]>

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PreContent<System.String[]>

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Property<System.Object[]>

Aliases

none

Required?

false

Position?

1

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Title<System.String>

Aliases

none

Required?

false

Position?

3

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see    about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • System.Management.Automation.PSObject

    You can pipe any object to ConvertTo-XML.


Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.String or System.Xml.XmlDocument

    The value of the As parameter determines the type of object that ConvertTo-XML returns.


Examples

-------------------------- EXAMPLE 1 --------------------------

This command converts the current date (a DateTime object) to XML.


get-date | convertto-xml

-------------------------- EXAMPLE 2 --------------------------

This command converts the process objects that represent all of the processes on the computer into an XML document. The objects are expanded to a depth of three levels.


convertto-xml -as Document -inputObject (get-process) -depth 3

Related topics

Community Additions

ADD
Show:
© 2016 Microsoft