CmdID

CmdID / PowerShell / Cmdlets / Export

Export-Clixml

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

From the PowerShell reference 9 parameters

Opens CmdID with your command, read as PowerShell. It is read in your browser and sent nowhere.

What it does

from the PowerShell reference, CC BY 4.0

Creates an XML-based representation of an object or objects and stores it in a file. The Export-Clixml cmdlet serialized an object into a Common Language Infrastructure (CLI) XML-based representation stores it in a file. You can then use the Import-Clixml cmdlet to recreate the saved object based on the contents of that file. For more information about CLI, see Language independence. 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 PowerShell. A valuable use of Export-Clixml on Windows computers is to export credentials and secure strings securely as XML. For an example, see Example 3.

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

Export a string to an XML file

"This is a test" | Export-Clixml -Path .\sample.xmlIdentify

Export an object to an XML file

Get-Acl C:\test.txt | Export-Clixml -Path .\FileACL.xml $fileacl = Import-Clixml -Path .\FileACL.xmlIdentify

Encrypt an exported credential object

$Credxmlpath = Join-Path (Split-Path $PROFILE) TestScript.ps1.credential $Credential | Export-Clixml $Credxmlpath $Credxmlpath = Join-Path (Split-Path $PROFILE) TestScript.ps1.credential $Credential = Import-Clixml $CredxmlpathIdentify

Trips 2 Sigma rules: highHackTool - CrackMapExec PowerShell Obfuscation by Thomas Patzke; lowPotential Encoded PowerShell Patterns In CommandLine by Teymur Kheirkhabarov (idea), Vasiliy Burov (rule), oscd.community, Tim Shelton

Its page in the reference: Export-Clixml.

Parameters

9 in the PowerShell reference
-DepthSpecifies 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.
-EncodingSpecifies the type of encoding for the target file. The default value is Unicode. The acceptable values for this parameter are as follows: - ASCII Uses ASCII (7-bit) character set. - BigEndianUnicode Uses UTF-16 with the big-endian byte order. - Default Uses the encoding that corresponds to the system's active code page (usually ANSI). - OEM Uses the encoding that corresponds to the system's current OEM code page. - Unicode Uses UTF-16 with the little-endian byte order. - UTF7 Uses UTF-7. - UTF8 Uses UTF-8. - UTF32 Uses UTF-32 with the little-endian byte order.
-ForceForces the command to run without asking for user confirmation. 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.
-InputObjectSpecifies 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.
-LiteralPathSpecifies 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's typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.
-NoClobberIndicates that the cmdlet doesn't overwrite the contents of an existing file. By default, if a file exists in the specified path, Export-Clixml overwrites the file without warning.
-PathSpecifies the path to the file where the XML representation of the object will be stored.
-ConfirmPrompts you for confirmation before running the cmdlet.
-WhatIfShows what would happen if the cmdlet runs. The cmdlet isn't run.