Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Export-Clixml

Export-Clixml

microsoft.powershell.commands.utility.dll

Synopsis

Creates an XML-based representation of an object or objects and stores it in a file.

Syntax

Export-Clixml [-Path] [-Depth] [-Encoding] [-Force] [-NoClobber] [-InputObject] [-Confirm] [-WhatIf] [<CommonParameters>]

Export-Clixml [-Depth] [-Encoding] [-Force] [-NoClobber] [-InputObject] [-LiteralPath] [-Confirm] [-WhatIf] [<CommonParameters>]

Detailed Description

The Export-Clixml cmdlet creates an XML-based representation of an object or objects and stores it in a file. You can then use the Import-CLIXML cmdlet to re-create the saved object based on the contents of that file.

This cmdlet is similar to ConvertTo-XML, 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

-Depth <Int32>

Specifies how many levels of contained objects are included in the XML representation. The default value is 2.

The default value can be overridden for the object type in the Types.ps1xml files. For more information, see about_Types.ps1xml.

Aliases

None

Required?

false

Position

named

Default value

2

Accept pipeline input?

false

Accept wildcard characters?

false

-Encoding <String>

Specifies the type of encoding for the target file. Valid values are ASCII, UTF8, UTF7, UTF32, Unicode, BigEndianUnicode, Default, and OEM. Unicode is the default.

Aliases

None

Required?

false

Position

named

Default value

Unicode

Accept pipeline input?

false

Accept wildcard characters?

false

-Force <SwitchParameter>

Causes the cmdlet to clear the read-only attribute of the output file if necessary. The cmdlet will attempt to reset the read-only attribute when the command completes.

Aliases

None

Required?

false

Position

named

Default value

False

Accept pipeline input?

false

Accept wildcard characters?

false

-InputObject <PSObject>

Specifies the object to be converted. Enter a variable that contains the objects, or type a command or expression that gets the objects. You can also pipe objects to Export-Clixml.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByValue)

Accept wildcard characters?

false

-NoClobber <SwitchParameter>

Ensures that the cmdlet does not overwrite the contents of an existing file. By default, if a file exists in the specified path, Export-Clixml overwrites the file without warning.

Aliases

NoOverwrite

Required?

false

Position

named

Default value

False

Accept pipeline input?

false

Accept wildcard characters?

false

-Path <String>

Specifies the path to the file where the XML representation of the object will be stored.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-LiteralPath <String>

Specifies the path to the file where the XML representation of the object will be stored. Unlike Path, the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-Confirm <SwitchParameter>

Prompts you for confirmation before running the cmdlet.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

-WhatIf <SwitchParameter>

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type

System.Management.Automation.PSObject

Return Type

System.IO.FileInfo

Notes

None

Examples

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

This command creates an XML file that stores a representation of the string, "This is a test".

PS C:\>"This is a test" | export-clixml sample.xml

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

This example shows how to export an object to an XML file and then create an object by importing the XML from the file.

The first command uses the Get-ACL cmdlet to get the security descriptor of the Test.txt file. It uses a pipeline operator to pass the security descriptor to Export-Clixml, which stores an XML-based representation of the object in a file named FileACL.xml.

The second command uses the Import-Clixml cmdlet to create an object from the XML in the FileACL.xml file. Then, it saves the object in the $FileAcl variable.

PS C:\>get-acl C:\test.txt | export-clixml -Path fileacl.xml
PS C:\>$fileacl = import-clixml fileacl.xml

Online Version
ConvertTo-Html
ConvertTo-Xml
Export-Csv
Import-Clixml