从键到值将哈希表导出到 csv
Export hashtable to csv from keys to value
好的,我正在努力解决这个问题。我需要将此散列 table 导出到 csv。
$Sku = @{
"AAD_BASIC" = "Azure Active Directory Basic"
"RMS_S_ENTERPRISE" = "Azure Active Directory Rights Management"
"AAD_PREMIUM" = "Azure Active Directory Premium P1"
"AAD_PREMIUM_P2" = "Azure Active Directory Premium P2"
"MFA_PREMIUM" = "Azure Multi-Factor Authentication"
"RIGHTSMANAGEMENT" = "Azure Information Protcetion Plan 1"
"O365_BUSINESS_ESSENTIALS" = "Office 365 Business Essentials"
"O365_BUSINESS_PREMIUM" = "Office 365 Business Premium"
"ADALLOM_O365" = "Office 365 Cloud App Security"
"ADALLOM_S_DISCOVERY" = "Unknown"
以上是散列的示例 table 您可以在此处找到该站点:https://github.com/directorcia/Office365/blob/master/o365-skus.ps1
当我导出时,它变得一团糟。我试图将其转换为 pscustom 对象。由于 table 的设置方式,我必须调用基本的 .物品。有没有办法引用 .item 而不是调用每个项目。我试过 .name 和 .value,都没有用。
哈希 table 可以很容易地直接转换为 PSCustomObject。 PSCustomObject 可以直接exported/converted转CSV.
$Sku = @{
"AAD_BASIC" = "Azure Active Directory Basic"
"RMS_S_ENTERPRISE" = "Azure Active Directory Rights Management"
"AAD_PREMIUM" = "Azure Active Directory Premium P1"
"AAD_PREMIUM_P2" = "Azure Active Directory Premium P2"
"MFA_PREMIUM" = "Azure Multi-Factor Authentication"
"RIGHTSMANAGEMENT" = "Azure Information Protcetion Plan 1"
"O365_BUSINESS_ESSENTIALS" = "Office 365 Business Essentials"
"O365_BUSINESS_PREMIUM" = "Office 365 Business Premium"
"ADALLOM_O365" = "Office 365 Cloud App Security"
"ADALLOM_S_DISCOVERY" = "Unknown"
}
[PSCustomObject]$sku | ConvertTo-Csv -NoTypeInformation
好的,我正在努力解决这个问题。我需要将此散列 table 导出到 csv。
$Sku = @{
"AAD_BASIC" = "Azure Active Directory Basic"
"RMS_S_ENTERPRISE" = "Azure Active Directory Rights Management"
"AAD_PREMIUM" = "Azure Active Directory Premium P1"
"AAD_PREMIUM_P2" = "Azure Active Directory Premium P2"
"MFA_PREMIUM" = "Azure Multi-Factor Authentication"
"RIGHTSMANAGEMENT" = "Azure Information Protcetion Plan 1"
"O365_BUSINESS_ESSENTIALS" = "Office 365 Business Essentials"
"O365_BUSINESS_PREMIUM" = "Office 365 Business Premium"
"ADALLOM_O365" = "Office 365 Cloud App Security"
"ADALLOM_S_DISCOVERY" = "Unknown"
以上是散列的示例 table 您可以在此处找到该站点:https://github.com/directorcia/Office365/blob/master/o365-skus.ps1
当我导出时,它变得一团糟。我试图将其转换为 pscustom 对象。由于 table 的设置方式,我必须调用基本的 .物品。有没有办法引用 .item 而不是调用每个项目。我试过 .name 和 .value,都没有用。
哈希 table 可以很容易地直接转换为 PSCustomObject。 PSCustomObject 可以直接exported/converted转CSV.
$Sku = @{
"AAD_BASIC" = "Azure Active Directory Basic"
"RMS_S_ENTERPRISE" = "Azure Active Directory Rights Management"
"AAD_PREMIUM" = "Azure Active Directory Premium P1"
"AAD_PREMIUM_P2" = "Azure Active Directory Premium P2"
"MFA_PREMIUM" = "Azure Multi-Factor Authentication"
"RIGHTSMANAGEMENT" = "Azure Information Protcetion Plan 1"
"O365_BUSINESS_ESSENTIALS" = "Office 365 Business Essentials"
"O365_BUSINESS_PREMIUM" = "Office 365 Business Premium"
"ADALLOM_O365" = "Office 365 Cloud App Security"
"ADALLOM_S_DISCOVERY" = "Unknown"
}
[PSCustomObject]$sku | ConvertTo-Csv -NoTypeInformation