ConvertTo-Expression

3.3.9

The ConvertTo-Expression cmdlet converts (serializes) an object to a
PowerShell expression. The object can be stored in a variable,  file or
any other common storage for later use or to be ported to another
system.

An expression can be restored to an object using the native
Invoke-Expression cmdlet:

   $Object = Invoke-Expression ($Object | ConverTo-Expression)

Or
The ConvertTo-Expression cmdlet converts (serializes) an object to a
PowerShell expression. The object can be stored in a variable,  file or
any other common storage for later use or to be ported to another
system.

An expression can be restored to an object using the native
Invoke-Expression cmdlet:

   $Object = Invoke-Expression ($Object | ConverTo-Expression)

Or Converting it to a [ScriptBlock] and invoking it with cmdlets
along with Invoke-Command or using the call operator (&):

   $Object = &([ScriptBlock]::Create($Object | ConverTo-Expression))

An expression that is stored in a PowerShell (.ps1) file might also
be directly invoked by the PowerShell dot-sourcing technique,  e.g.:

   $Object | ConvertTo-Expression | Out-File .\Expression.ps1
   $Object = . .\Expression.ps1

Warning: Invoking partly trusted input with Invoke-Expression or
[ScriptBlock]::Create() methods could be abused by malicious code
injections.

Show more

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Script -Name ConvertTo-Expression

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Author(s)

Ronald Bode (iRon)

Package Details

Owners

Tags

PSON PowerShell Object Notation Expression Serialize Stringify

Functions

Serialize Quote QuoteKey Here Stringify GetTypeName Prefix Iterate

Dependencies

This script has no dependencies.

FileList

Version History

Version Downloads Last updated
3.3.9 (current version) 15 8/31/2022
3.3.7 436 11/16/2020
3.3.6 30 11/1/2020
3.3.0 186 5/11/2020
3.2.19 97 10/19/2019
3.2.16 19 10/18/2019
3.2.12 45 8/29/2019
3.2.10 41 7/20/2019
3.2.9 24 6/26/2019
3.1.1 155 1/7/2019
3.1.0 24 1/5/2019
3.0.4 45 12/14/2018
3.0.2 19 12/13/2018
3.0.1 23 12/1/2018
2.7.0 34 8/30/2018
2.6.0 22 8/28/2018
2.4.6 33 8/2/2018
2.4.2 30 6/21/2018
2.4.1 21 6/21/2018
2.3.0 57 1/27/2018
Show more