PowerShell Logo Small

Import-Clixml



This is the built-in help made by Microsoft for the command 'Import-Clixml', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Imports a CLIXML file and creates corresponding objects within Windows PowerShell.

SYNTAX


Import-Clixml [-Path] <String[]> [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]] [-First
[<SwitchParameter>]] [-Skip [<SwitchParameter>]] [-IncludeTotalCount [<SwitchParameter>]] [<CommonParameters>]
Import-Clixml [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]] -LiteralPath <String[]> [-First
[<SwitchParameter>]] [-Skip [<SwitchParameter>]] [-IncludeTotalCount [<SwitchParameter>]] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Import-CliXml cmdlet imports a CLIXML file with data that represents Microsoft .NET Framework objects and creates the objects in Windows PowerShell.


A valuable use of Import-CliXml is to import credentials and secure strings that have been exported as secure XML by running the Export-CliXml cmdlet. For an example of how
to do this, see Example 2 in this topic.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=293982
Use PowerShell to Pass Credentials to Legacy Systems
Securely Store Credentials on Disk
Export-CliXml

REMARKS

<

Examples


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

PS C:\>get-process | export-clixml pi.xml
PS C:\>$processes = import-clixml pi.xml



This command uses the Export-Clixml cmdlet to save a serialized copy of the process information returned by Get-Process. It then uses Import-Clixml to retrieve the contents
of the serialized file and re-create an object that is stored in the $processes variable.










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

PS C:\>$credxmlpath = Join-Path (Split-Path $profile) TestScript.ps1.credential
PS C:\>$credential | Export-CliXml $credxmlpathPS C:\>$credxmlpath = Join-Path (Split-Path $profile) TestScript.ps1.credential
PS C:\>$credential = Import-CliXml $credxmlpath



The Export-CliXml cmdlet encrypts credential objects by using the Windows Data Protection API. This ensures that only your user account can decrypt the contents of the
credential object.

In this example, given a credential that you’ve stored in the $credential variable by running the Get-Credential cmdlet, you can run the Export-CliXml cmdlet to save the
credential to disk.In the example, the file in which the credential is stored is represented by TestScript.ps1.credential. Replace TestScript with the name of the script
with which you are loading the credential.

In the second command, you pipe the credential object to Export-CliXml, and save it to the path, $credxmlpath, that you specified in the first command.





To import the credential automatically into your script, run the final two commands. This time, you are running Import-CliXml to import the secured credential object into
your script. This eliminates the risk of exposing plain-text passwords in your script.