-
Notifications
You must be signed in to change notification settings - Fork 4
Description
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
}