【发布时间】:2022-09-23 16:43:18
【问题描述】:
我有下面的代码,在其中我在不同的数组中获取所需的数据。该数组具有列标题和与之关联的值
$GetEnabledControls=@()
$CiphersTable=@()
$HashesTable=@()
$KeyTable=@()
$ServersTable=@()
$ClientsTable=@()
$GetEnabledControls = Get-ChildItem \"HKLM:\\SYSTEM\\CurrentControlSet\\Control\\SecurityProviders\\SCHANNEL\" -Recurse | ForEach-Object {
Get-ItemProperty $_.PSPath | Where-Object { $_.Enabled -ne \'0\' }
}
foreach($entry in $GetEnabledControls)
{
$PSPath =$entry.PSPath
$regex = \"Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\SecurityProviders\\SCHANNEL\\\"
$ShortPath = $PSPath.Replace($regex,\"\")
$SplitShortPath = $ShortPath.Split(\"\\\")
$type = $SplitShortPath[0]
$value = $SplitShortPath[1]
if($type -eq \'Ciphers\'){
$CiphersTable += [PSCustomObject]@{
$type = $value
}
}
if($type -eq \'Hashes\'){
$HashesTable += [PSCustomObject]@{
$type = $value
}
}
if($type -eq \'KeyExchangeAlgorithms\'){
$KeyTable += [PSCustomObject]@{
$type = $value
}
}
if($type -eq \'Protocols\'){
$GetChild = $entry.PSChildName
if($GetChild -eq \'Server\'){
$type=\'Server Protocols\'
$ServersTable += [PSCustomObject]@{
$type = $value
}
}
else
{
if($GetChild -eq \'Client\'){
$type=\'Client Protocols\'
$ClientsTable += [PSCustomObject]@{
$type = $value
}
}
}
}
}
上面的每个数组都有如下数据
$CiphersTable=@()
Ciphers
-------
AES 128/128
AES 256/256
$HashesTable=@()
Hashes
------
SHA256
SHA384
SHA512
$KeyTable=@()
KeyExchangeAlgorithms
---------------------
ECDH
PKCS
请让我知道如何将这些数据写入 csv 中的单独列。 需要在 csv 文件中如下所示的输出
Ciphers Hashes KeyExchangeAlgorithms
AES 128/128 SHA512 ECDH
AES 256/256 SHA384 PKCS
SHA512
标签: powershell