Skip to content

When exporting catalogue variables are evaluated and then not exported correctly #14

@AleksPish

Description

@AleksPish

When exporting snippets to .json with export-psnote the stored vairables are evaluated against the current powershell session which causes the values to either not show in exported snippet if value is null, or show as value saved in variable, rather than variable name as would be required to maintain consistency

Example snippet to be exported:

❯ Get-ExpiredCertificates
Get-ChildItem cert:\ -Recurse | Where-Object {$_ -is [System.Security.Cryptography.X509Certificates.X509Certificate2] -and $_.NotAfter -lt (Get-Date)} | Select-Object -Property FriendlyName,NotAfter

Exported .json file:

❯ gc .\export.json
{
"Catalog": "Certs",
"StoreVersion": 1,
"Notes": [
{
"Name": "Get-ExpiredCertificates",
"Snippet": "Get-ChildItem cert:\ -Recurse | Where-Object { -is [System.Security.Cryptography.X509Certificates.X509Certificate2] -and .NotAfter -lt (Get-Date)} | Select-Object -Property FriendlyName,NotAfter",
"Details": "",
"Alias": "Get-ExpiredCertificates",
"Tags": null,
"Catalog": "Certs",
"Run": false,
"Kind": 0
},
null
],
"IsRemote": false
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs clarificationmore information is required from the submitter

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions