From 0de0488a31c8d133d2cc046bfdc71d5763888370 Mon Sep 17 00:00:00 2001 From: Charlie Schmidt Date: Mon, 8 Jan 2018 23:43:25 -0500 Subject: [PATCH 1/6] Cmdlet help for ConvertFrom-Clixml and ConvertTo-Clixml for Powershell#3898 --- .../ConvertFrom-Clixml.md | 179 ++++++++++++++++ .../ConvertTo-Clixml.md | 194 ++++++++++++++++++ .../Export-Clixml.md | 4 + .../Import-Clixml.md | 4 + 4 files changed, 381 insertions(+) create mode 100644 reference/6/Microsoft.PowerShell.Utility/ConvertFrom-Clixml.md create mode 100644 reference/6/Microsoft.PowerShell.Utility/ConvertTo-Clixml.md diff --git a/reference/6/Microsoft.PowerShell.Utility/ConvertFrom-Clixml.md b/reference/6/Microsoft.PowerShell.Utility/ConvertFrom-Clixml.md new file mode 100644 index 000000000000..27ccf0e87e6e --- /dev/null +++ b/reference/6/Microsoft.PowerShell.Utility/ConvertFrom-Clixml.md @@ -0,0 +1,179 @@ +--- +ms.date: 2017-06-09 +schema: 2.0.0 +locale: en-us +keywords: powershell,cmdlet +online version: +external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml +title: ConvertFrom-Clixml +--- + +# ConvertFrom-Clixml + +## SYNOPSIS +Converts an CLIXML string into new corresponding object in Windows PowerShell. + +## SYNTAX + +``` +ConvertFrom-Clixml -InputObject [-InformationAction ] [-InformationVariable ] + [-IncludeTotalCount] [-Skip ] [-First ] [] +``` + +## DESCRIPTION +The **ConvertFrom-CliXml** cmdlet converts a CLIXML string with data that represents Microsoft .NET Framework objects and creates the objects in Windows PowerShell. + +A valuable use of **ConvertFrom-CliXml** is to deserialize credentials and secure strings that have been serialized as secure XML by running the ConvertTo-Clixml cmdlet. +For an example of how to do this, see Example 2. + +## EXAMPLES + +### Example 1: Import a serialized file and recreate an object +``` +PS C:\> $clixml = Get-Process | ConvertTo-Clixml +PS C:\> $Processes = ConvertFrom-Clixml $clixml +``` + +This command uses the ConvertTo-Clixml cmdlet to create a serialized copy of the process information returned by Get-Process. +It then uses **ConvertFrom-Clixml** to retrieve the contents of the serialized string and re-create an object that is stored in the $Processes variable. + +### Example 3: Convert an encrypted credential object +``` +PS C:\> $CredXml = $Credential | ConvertTo-Clixml +PS C:\> $Credential = ConvertFrom-CliXml $CredXml +``` + +The **ConvertTo-CliXml** cmdlet encrypts credential objects by using the Windows Data Protection API http://msdn.microsoft.com/library/windows/apps/xaml/hh464970.aspx. +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 **ConvertTo-CliXml** cmdlet to serialize the credential to a string. + +To deserialize the credential later, run the second command. +This time, you are running ConvertFrom-Clixml to import the secured credential object into your script. +This eliminates the risk of exposing plain-text passwords in your script. + +## PARAMETERS + +### -InformationAction +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: infa +Accepted values: SilentlyContinue, Stop, Continue, Inquire, Ignore, Suspend + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InformationVariable +```yaml +Type: String +Parameter Sets: (All) +Aliases: iv + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +Specifies the CLIXML string to be converted to objects. +You can also pipe the CLIXML string to **ConvertFrom-Clixml**. + +```yaml +Type: string +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### -First +Gets only the specified number of objects. +Enter the number of objects to get. + +```yaml +Type: UInt64 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Skip +Ignores the specified number of objects and then gets the remaining objects. +Enter the number of objects to skip. + +```yaml +Type: UInt64 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -IncludeTotalCount +Reports the total number of objects in the data set (an integer) followed by the selected objects. +If the cmdlet cannot determine the total count, it displays "Unknown total count." The integer has an Accuracy property that indicates the reliability of the total count value. +The value of Accuracy ranges from 0.0 to 1.0 where 0.0 means that the cmdlet could not count the objects, 1.0 means that the count is exact, and a value between 0.0 and 1.0 indicates an increasingly reliable estimate. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +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 (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String +You can pipe a string that contains a path to **ConvertFrom-Clixml**. + +## OUTPUTS + +### PSObject +**ConvertFrom-Clixml** returns objects that have been deserialized from the stored XML files. + +## NOTES +* When specifying multiple values for a parameter, use commas to separate the values. For example, "\ \, \". + +* + +## RELATED LINKS + +[Use PowerShell to Pass Credentials to Legacy Systems](http://blogs.technet.com/b/heyscriptingguy/archive/2011/06/05/use-powershell-to-pass-credentials-to-legacy-systems.aspx) + +[Securely Store Credentials on Disk](http://powershellcookbook.com/recipe/PukO/securely-store-credentials-on-disk) + +[Export-Clixml](Export-Clixml.md) + +[Import-Clixml](Import-Clixml.md) + +[ConvertTo-Clixml](ConvertTo-Clixml.md) + + diff --git a/reference/6/Microsoft.PowerShell.Utility/ConvertTo-Clixml.md b/reference/6/Microsoft.PowerShell.Utility/ConvertTo-Clixml.md new file mode 100644 index 000000000000..4bf3b4970a34 --- /dev/null +++ b/reference/6/Microsoft.PowerShell.Utility/ConvertTo-Clixml.md @@ -0,0 +1,194 @@ +--- +ms.date: 2017-06-09 +schema: 2.0.0 +locale: en-us +keywords: powershell,cmdlet +online version: +external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml +title: ConvertTo-Clixml +--- + +# ConvertTo-Clixml + +## SYNOPSIS +Converts objects to an XML-based representation and returns that as a string. + +## SYNTAX + +``` +ConvertTo-Clixml [-Depth ] -InputObject [-Encoding ] + [-InformationAction ] [-InformationVariable ] + [] +``` + +## DESCRIPTION +The **ConvertTo-CliXml** cmdlet creates XML-based representations of objects and returns them as strings. +You can then use the **ConvertFrom-Clixml** cmdlet to re-create the saved objects based on the contents of the strings. + +A valuable use of **ConvertTo-CliXml** is to serialize credentials and secure strings securely as XML. +For an example of how to do this, see Example 3. + +## EXAMPLES + +### Example 1: Convert a string to an XML representation +``` +PS C:\> "This is a test" | ConvertTo-Clixml +``` + +This command returns a string with am XML-based representation of the string object with a value of "This is a test". + +### Example 2: Convert an object to an XML-based representation +``` +PS C:\> $FileaclString = Get-Acl C:\test.txt | ConvertTo-Clixml +PS C:\> $Fileacl = ConvertFrom-Clixml $FileaclString +``` + +This example shows how to convert an object to an XML string and then create an object by converting the XML from the string. + +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 **ConvertTo-Clixml**, which converts the object to an XML-based representation and returns that as a string. +Then, it saves the string in the $FileAclString variable. + +The second command uses the ConvertFrom-Clixml cmdlet to create an object from the XML in the $FileAclString variable. +Then, it saves the object in the $FileAcl variable. + +### Example 3: Convert an encrypted credential object +``` +PS C:\> $CredXml = $Credential | ConvertTo-Clixml +PS C:\> $Credential = ConvertFrom-CliXml $CredXml +``` + +The **ConvertTo-CliXml** cmdlet encrypts credential objects by using the Windows Data Protection API http://msdn.microsoft.com/library/windows/apps/xaml/hh464970.aspx. +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 **ConvertTo-CliXml** cmdlet to serialize the credential to a string. + +To deserialize the credential later, run the second command. +This time, you are running ConvertFrom-Clixml to import the secured credential object into your script. +This eliminates the risk of exposing plain-text passwords in your script. + +## PARAMETERS + +### -Depth +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. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Encoding +Specifies the type of encoding for the target file. +The acceptable values for this parameter are: + +- ASCII +- UTF8 +- UTF7 +- UTF32 +- Unicode +- BigEndianUnicode +- Default +- OEM + +The default value is Unicode. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: Unicode, UTF7, UTF8, ASCII, UTF32, BigEndianUnicode, Default, OEM + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InformationAction +The default value can be overridden for the object type in the Types.ps1xml files. For more information, see about_Types.ps1xml.```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: infa +Accepted values: SilentlyContinue, Stop, Continue, Inquire, Ignore, Suspend + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InformationVariable +The default value can be overridden for the object type in the Types.ps1xml files. For more information, see about_Types.ps1xml.```yaml +Type: String +Parameter Sets: (All) +Aliases: iv + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +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 **ConvertTo-Clixml**. + +```yaml +Type: PSObject +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +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 (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.Management.Automation.PSObject +You can pipe any object to **ConvertTo-Clixml**. + +## OUTPUTS + +### System.String +The XML-based representation is returned as a collection of strings. + +## NOTES + +## RELATED LINKS + +[Use PowerShell to Pass Credentials to Legacy Systems](http://blogs.technet.com/b/heyscriptingguy/archive/2011/06/05/use-powershell-to-pass-credentials-to-legacy-systems.aspx) + +[Securely Store Credentials on Disk](http://powershellcookbook.com/recipe/PukO/securely-store-credentials-on-disk) + +[ConvertTo-Json](ConvertTo-Json.md) + +[ConvertTo-Xml](ConvertTo-Xml.md) + +[ConvertTo-Csv](ConvertTo-Csv.md) + +[Export-Clixml](Export-Clixml.md) + +[Import-Clixml](Import-Clixml.md) + +[ConvertFrom-Clixml](ConvertFrom-Clixml.md) diff --git a/reference/6/Microsoft.PowerShell.Utility/Export-Clixml.md b/reference/6/Microsoft.PowerShell.Utility/Export-Clixml.md index 8ae22d949270..563085afcfc9 100644 --- a/reference/6/Microsoft.PowerShell.Utility/Export-Clixml.md +++ b/reference/6/Microsoft.PowerShell.Utility/Export-Clixml.md @@ -301,5 +301,9 @@ You can pipe any object to **Export-Clixml**. [Export-Csv](Export-Csv.md) +[ConvertTo-Clixml](ConvertTo-Clixml.md) + +[ConvertFrom-Clixml](ConvertFrom-Clixml.md) + [Import-Clixml](Import-Clixml.md) diff --git a/reference/6/Microsoft.PowerShell.Utility/Import-Clixml.md b/reference/6/Microsoft.PowerShell.Utility/Import-Clixml.md index 9b10800a07a1..cbbba1ec56ce 100644 --- a/reference/6/Microsoft.PowerShell.Utility/Import-Clixml.md +++ b/reference/6/Microsoft.PowerShell.Utility/Import-Clixml.md @@ -202,5 +202,9 @@ You can pipe a string that contains a path to **Import-Clixml**. [Securely Store Credentials on Disk](http://powershellcookbook.com/recipe/PukO/securely-store-credentials-on-disk) +[ConvertTo-Clixml](ConvertTo-Clixml.md) + +[ConvertFrom-Clixml](ConvertFrom-Clixml.md) + [Export-Clixml](Export-Clixml.md) From 33b07515f9943540d5d4215cad4a79ab5e8aebfd Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Tue, 9 Jan 2018 07:27:31 -0800 Subject: [PATCH 2/6] minor edits - Removed -information* common parameters - reformat code blocks - renumbered example --- .../ConvertFrom-Clixml.md | 49 +++++-------------- 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/reference/6/Microsoft.PowerShell.Utility/ConvertFrom-Clixml.md b/reference/6/Microsoft.PowerShell.Utility/ConvertFrom-Clixml.md index 27ccf0e87e6e..7591d34b5e8c 100644 --- a/reference/6/Microsoft.PowerShell.Utility/ConvertFrom-Clixml.md +++ b/reference/6/Microsoft.PowerShell.Utility/ConvertFrom-Clixml.md @@ -16,8 +16,7 @@ Converts an CLIXML string into new corresponding object in Windows PowerShell. ## SYNTAX ``` -ConvertFrom-Clixml -InputObject [-InformationAction ] [-InformationVariable ] - [-IncludeTotalCount] [-Skip ] [-First ] [] +ConvertFrom-Clixml -InputObject [-IncludeTotalCount] [-Skip ] [-First ] [] ``` ## DESCRIPTION @@ -29,21 +28,24 @@ For an example of how to do this, see Example 2. ## EXAMPLES ### Example 1: Import a serialized file and recreate an object -``` -PS C:\> $clixml = Get-Process | ConvertTo-Clixml -PS C:\> $Processes = ConvertFrom-Clixml $clixml + +```powershell +$clixml = Get-Process | ConvertTo-Clixml +$Processes = ConvertFrom-Clixml $clixml ``` This command uses the ConvertTo-Clixml cmdlet to create a serialized copy of the process information returned by Get-Process. It then uses **ConvertFrom-Clixml** to retrieve the contents of the serialized string and re-create an object that is stored in the $Processes variable. -### Example 3: Convert an encrypted credential object -``` -PS C:\> $CredXml = $Credential | ConvertTo-Clixml -PS C:\> $Credential = ConvertFrom-CliXml $CredXml +### Example 2: Convert an encrypted credential object + +```powershell +$CredXml = $Credential | ConvertTo-Clixml +$Credential = ConvertFrom-CliXml $CredXml ``` -The **ConvertTo-CliXml** cmdlet encrypts credential objects by using the Windows Data Protection API http://msdn.microsoft.com/library/windows/apps/xaml/hh464970.aspx. +The **ConvertTo-CliXml** cmdlet encrypts credential objects by using the +[Windows Data Protection API](http://msdn.microsoft.com/library/windows/apps/xaml/hh464970.aspx). 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 **ConvertTo-CliXml** cmdlet to serialize the credential to a string. @@ -54,33 +56,6 @@ This eliminates the risk of exposing plain-text passwords in your script. ## PARAMETERS -### -InformationAction -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: infa -Accepted values: SilentlyContinue, Stop, Continue, Inquire, Ignore, Suspend - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InformationVariable -```yaml -Type: String -Parameter Sets: (All) -Aliases: iv - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -InputObject Specifies the CLIXML string to be converted to objects. You can also pipe the CLIXML string to **ConvertFrom-Clixml**. From c47abeb74dce698c59ffab96bd64b91ff40b963a Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Tue, 9 Jan 2018 07:31:30 -0800 Subject: [PATCH 3/6] minor updates - reformatted examples - removed common paramters --- .../ConvertTo-Clixml.md | 55 +++++-------------- 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/reference/6/Microsoft.PowerShell.Utility/ConvertTo-Clixml.md b/reference/6/Microsoft.PowerShell.Utility/ConvertTo-Clixml.md index 4bf3b4970a34..dfca81a1ca09 100644 --- a/reference/6/Microsoft.PowerShell.Utility/ConvertTo-Clixml.md +++ b/reference/6/Microsoft.PowerShell.Utility/ConvertTo-Clixml.md @@ -16,9 +16,7 @@ Converts objects to an XML-based representation and returns that as a string. ## SYNTAX ``` -ConvertTo-Clixml [-Depth ] -InputObject [-Encoding ] - [-InformationAction ] [-InformationVariable ] - [] +ConvertTo-Clixml [-Depth ] -InputObject [-Encoding ] [] ``` ## DESCRIPTION @@ -31,16 +29,18 @@ For an example of how to do this, see Example 3. ## EXAMPLES ### Example 1: Convert a string to an XML representation -``` -PS C:\> "This is a test" | ConvertTo-Clixml + +```powershell +"This is a test" | ConvertTo-Clixml ``` This command returns a string with am XML-based representation of the string object with a value of "This is a test". ### Example 2: Convert an object to an XML-based representation -``` -PS C:\> $FileaclString = Get-Acl C:\test.txt | ConvertTo-Clixml -PS C:\> $Fileacl = ConvertFrom-Clixml $FileaclString + +```powershell +$FileaclString = Get-Acl C:\test.txt | ConvertTo-Clixml +Fileacl = ConvertFrom-Clixml $FileaclString ``` This example shows how to convert an object to an XML string and then create an object by converting the XML from the string. @@ -53,12 +53,14 @@ The second command uses the ConvertFrom-Clixml cmdlet to create an object from t Then, it saves the object in the $FileAcl variable. ### Example 3: Convert an encrypted credential object -``` -PS C:\> $CredXml = $Credential | ConvertTo-Clixml -PS C:\> $Credential = ConvertFrom-CliXml $CredXml + +```powershell +$CredXml = $Credential | ConvertTo-Clixml +$Credential = ConvertFrom-CliXml $CredXml ``` -The **ConvertTo-CliXml** cmdlet encrypts credential objects by using the Windows Data Protection API http://msdn.microsoft.com/library/windows/apps/xaml/hh464970.aspx. +The **ConvertTo-CliXml** cmdlet encrypts credential objects by using the +[Windows Data Protection API](http://msdn.microsoft.com/library/windows/apps/xaml/hh464970.aspx). 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 **ConvertTo-CliXml** cmdlet to serialize the credential to a string. @@ -116,33 +118,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -InformationAction -The default value can be overridden for the object type in the Types.ps1xml files. For more information, see about_Types.ps1xml.```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: infa -Accepted values: SilentlyContinue, Stop, Continue, Inquire, Ignore, Suspend - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InformationVariable -The default value can be overridden for the object type in the Types.ps1xml files. For more information, see about_Types.ps1xml.```yaml -Type: String -Parameter Sets: (All) -Aliases: iv - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -InputObject Specifies the object to be converted. Enter a variable that contains the objects, or type a command or expression that gets the objects. @@ -161,7 +136,7 @@ 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 (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](../../Microsoft.PowerShell.Core/About/about_CommonParameters.md). ## INPUTS From fde1fc61395b4d38c50e841dd9f8e7a69e9b9fa8 Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Tue, 9 Jan 2018 07:32:08 -0800 Subject: [PATCH 4/6] update link to about topic --- reference/6/Microsoft.PowerShell.Utility/ConvertFrom-Clixml.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/6/Microsoft.PowerShell.Utility/ConvertFrom-Clixml.md b/reference/6/Microsoft.PowerShell.Utility/ConvertFrom-Clixml.md index 7591d34b5e8c..32bcb7b11aff 100644 --- a/reference/6/Microsoft.PowerShell.Utility/ConvertFrom-Clixml.md +++ b/reference/6/Microsoft.PowerShell.Utility/ConvertFrom-Clixml.md @@ -122,7 +122,7 @@ 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 (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](../../Microsoft.PowerShell.Core/About/about_CommonParameters.md). ## INPUTS From 3989ca4280bcadb489d9e289754ccce106b8403e Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Tue, 9 Jan 2018 07:36:13 -0800 Subject: [PATCH 5/6] minor edits - removed common parameters - formatted code blocks --- .../Export-Clixml.md | 58 +++++-------------- 1 file changed, 16 insertions(+), 42 deletions(-) diff --git a/reference/6/Microsoft.PowerShell.Utility/Export-Clixml.md b/reference/6/Microsoft.PowerShell.Utility/Export-Clixml.md index 563085afcfc9..8507862cf847 100644 --- a/reference/6/Microsoft.PowerShell.Utility/Export-Clixml.md +++ b/reference/6/Microsoft.PowerShell.Utility/Export-Clixml.md @@ -18,15 +18,13 @@ Creates an XML-based representation of an object or objects and stores it in a f ### ByPath (Default) ``` Export-Clixml [-Depth ] [-Path] -InputObject [-Force] [-NoClobber] - [-Encoding ] [-InformationAction ] [-InformationVariable ] [-WhatIf] - [-Confirm] [] + [-Encoding ] [-WhatIf] [-Confirm] [] ``` ### ByLiteralPath ``` Export-Clixml [-Depth ] -LiteralPath -InputObject [-Force] [-NoClobber] - [-Encoding ] [-InformationAction ] [-InformationVariable ] [-WhatIf] - [-Confirm] [] + [-Encoding ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -42,16 +40,18 @@ For an example of how to do this, see Example 3. ## EXAMPLES ### Example 1: Export a string to an XML file -``` -PS C:\> "This is a test" | Export-Clixml sample.xml + +```powershell +"This is a test" | Export-Clixml sample.xml ``` This command creates an XML file that stores a representation of the string, "This is a test". ### Example 2: Export an object to an XML file -``` -PS C:\> Get-Acl C:\test.txt | Export-Clixml -Path "fileacl.xml" -PS C:\> $Fileacl = Import-Clixml "fileacl.xml" + +```powershell +Get-Acl C:\test.txt | Export-Clixml -Path "fileacl.xml" +$Fileacl = Import-Clixml "fileacl.xml" ``` This example shows how to export an object to an XML file and then create an object by importing the XML from the file. @@ -63,11 +63,12 @@ The second command uses the Import-Clixml cmdlet to create an object from the XM Then, it saves the object in the $FileAcl variable. ### Example 3: Encrypt an exported credential object -``` -PS C:\> $CredXmlPath = Join-Path (Split-Path $Profile) TestScript.ps1.credential -PS C:\> $credential | Export-CliXml $CredPath -PS C:\> $CredXmlPath = Join-Path (Split-Path $Profile) TestScript.ps1.credential -PS C:\> $Credential = Import-CliXml $CredXmlPath + +```powershell +$CredXmlPath = Join-Path (Split-Path $Profile) TestScript.ps1.credential +$credential | Export-CliXml $CredPath +$CredXmlPath = Join-Path (Split-Path $Profile) TestScript.ps1.credential +$Credential = Import-CliXml $CredXmlPath ``` The **Export-CliXml** cmdlet encrypts credential objects by using the Windows Data Protection APIhttp://msdn.microsoft.com/library/windows/apps/xaml/hh464970.aspx. @@ -149,33 +150,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -InformationAction -The default value can be overridden for the object type in the Types.ps1xml files. For more information, see about_Types.ps1xml.```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: infa -Accepted values: SilentlyContinue, Stop, Continue, Inquire, Ignore, Suspend - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InformationVariable -The default value can be overridden for the object type in the Types.ps1xml files. For more information, see about_Types.ps1xml.```yaml -Type: String -Parameter Sets: (All) -Aliases: iv - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -InputObject Specifies the object to be converted. Enter a variable that contains the objects, or type a command or expression that gets the objects. @@ -275,7 +249,7 @@ 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 (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](../../Microsoft.PowerShell.Core/About/about_CommonParameters.md). ## INPUTS From 60caac493ba34e77e84b196a11a794eb8f1961e8 Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Tue, 9 Jan 2018 07:37:47 -0800 Subject: [PATCH 6/6] minor edits - reformatted code blocks - removed common parameters --- .../Import-Clixml.md | 53 +++++-------------- 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/reference/6/Microsoft.PowerShell.Utility/Import-Clixml.md b/reference/6/Microsoft.PowerShell.Utility/Import-Clixml.md index cbbba1ec56ce..84bf429635d1 100644 --- a/reference/6/Microsoft.PowerShell.Utility/Import-Clixml.md +++ b/reference/6/Microsoft.PowerShell.Utility/Import-Clixml.md @@ -17,14 +17,12 @@ Imports a CLIXML file and creates corresponding objects in Windows PowerShell. ### ByPath (Default) ``` -Import-Clixml [-Path] [-InformationAction ] [-InformationVariable ] - [-IncludeTotalCount] [-Skip ] [-First ] [] +Import-Clixml [-Path] [-IncludeTotalCount] [-Skip ] [-First ] [] ``` ### ByLiteralPath ``` -Import-Clixml -LiteralPath [-InformationAction ] [-InformationVariable ] - [-IncludeTotalCount] [-Skip ] [-First ] [] +Import-Clixml -LiteralPath [-IncludeTotalCount] [-Skip ] [-First ] [] ``` ## DESCRIPTION @@ -36,20 +34,22 @@ For an example of how to do this, see Example 2. ## EXAMPLES ### Example 1: Import a serialized file and recreate an object -``` -PS C:\> Get-Process | Export-Clixml pi.xml -PS C:\> $Processes = Import-Clixml pi.xml + +```powershell +Get-Process | Export-Clixml pi.xml +$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: Import a secure credential object -``` -PS C:\> $Credxmlpath = Join-Path (Split-Path $Profile) TestScript.ps1.credential -PS C:\> $Credential | Export-CliXml $Credxmlpath -PS C:\> $Credxmlpath = Join-Path (Split-Path $Profile) TestScript.ps1.credential -PS C:\> $Credential = Import-CliXml $Credxmlpath + +```powershell +$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 $Credxmlpath ``` The **Export-CliXml** cmdlet encrypts credential objects by using the Windows Data Protection APIhttp://msdn.microsoft.com/library/windows/apps/xaml/hh464970.aspx. @@ -68,33 +68,6 @@ This eliminates the risk of exposing plain-text passwords in your script. ## PARAMETERS -### -InformationAction -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: infa -Accepted values: SilentlyContinue, Stop, Continue, Inquire, Ignore, Suspend - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InformationVariable -```yaml -Type: String -Parameter Sets: (All) -Aliases: iv - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -Path Specifies the XML files. @@ -179,7 +152,7 @@ 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 (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](../../Microsoft.PowerShell.Core/About/about_CommonParameters.md). ## INPUTS