我正在尝试将集合哈希表项的名称/值对导出到 CSV。我没有找到代码的选择对象部分的正确语法。我希望 CSV 文件包含 Url 和 Owner 的列。谢谢您的帮助
[System.Collections.ArrayList]$collection = New-Object System.Collections.ArrayList($null)
$SiteInfo = @{};
$SiteInfo.Url = "http://some.url.com";
$SiteInfo.Owner = "Joe Smith";
$collection.Add($SiteInfo);
$SiteInfo.Url = "http://another.url.com";
$SiteInfo.Owner = "Sally Jones";
$collection.Add($SiteInfo);
$collection | foreach{
$hashTableDate = $_;
$hashTableDate | Select-Object -Property Url, Owner;
}| Export-Csv "C:\UsageReport.csv" -NoTypeInformation -Encoding UTF8 -Delimiter '|'
# results: file is empty :(