PowerShell Rename Hashtable Properties

This is a brief demonstration of how we can rename property names uniformly across a hash table, effectively renaming the “Column Name” that will be output if we generate a CSV.

1
2
3
4
5
6
$Data = Get-Content -Path ~\jsonextract.json | ConvertFrom-Json -AsHashtable
foreach($D in $Data)
{
    $D.newPropertyName = $D.oldPropertyName;
    $D.Remove("oldPropertyName");
}
Built with Hugo
Theme Stack designed by Jimmy