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) 123 8/31/2022
3.3.7 446 11/16/2020
3.3.6 40 11/1/2020
3.3.0 198 5/11/2020
3.2.19 107 10/19/2019
3.2.16 30 10/18/2019
3.2.12 56 8/29/2019
3.2.10 51 7/20/2019
3.2.9 34 6/26/2019
3.1.1 181 1/7/2019
3.1.0 35 1/5/2019
3.0.4 56 12/14/2018
3.0.2 29 12/13/2018
3.0.1 33 12/1/2018
2.7.0 44 8/30/2018
2.6.0 32 8/28/2018
2.4.6 43 8/2/2018
2.4.2 40 6/21/2018
2.4.1 32 6/21/2018
2.3.0 67 1/27/2018
Show more