0
我使用下面的查詢服務器列表的防火牆規則。PowerShell的 - 服務器導出查詢防火牆列表到csv
$servers = Get-Content fw_servers.txt
foreach($serv in $servers) {
$fw = New-Object -ComObject hnetcfg.fwpolicy2
$fw.rules |
Where-Object { $_.enabled -and $_.LocalPorts -like 3389 } |
Select-Object -Property direction,protocol, localports,name
}
我想將此信息導出到csv文件。有人可以讓我知道我可以如何使用Export-CSV?我試過把它變成一個數組,但它不適合我。我使用的是2.0
我也喜歡將導出的數據看起來像下面
Server Direction Protocol LocalPorts Name
testsrv1 1 6 3389 Remote Desktop (TCP-In)
testsrv2 1 6 3389 Research Remote Desktop Policy
謝謝您的幫助。
Amelia