
작동하는 PowerShell 스크립트가 있지만 문제는 Excel 시트와 같은 출력 표를 가져오는 것입니다.
코드는 다음과 같습니다.
Get-NetFirewallRule |
Where-Object {($_.Profiles -band [Microsoft.PowerShell.Cmdletization.GeneratedTypes.NetSecurity.Profile]::Domain) -or ($_.Profiles -eq [Microsoft.PowerShell.Cmdletization.GeneratedTypes.NetSecurity.Profile]::Any)} |
ForEach-Object {
$portFilter = Get-NetFirewallPortFilter -AssociatedNetFirewallRule $_
$_ | Select-Object -Property `
Name,
DisplayName,
DisplayGroup,
Profiles,
Direction,
@{n='Protocol'; e={$portFilter.Protocol}},
@{n='LocalPort'; e={$portFilter.LocalPort}},
@{n='RemotePort'; e={$portFilter.RemotePort}},
@{n='RemoteAddress'; e={(Get-NetFirewallAddressFilter -AssociatedNetFirewallRule $_).RemoteAddress}},
Enabled,
Profile,
Action
}
Excel 스프레드시트처럼 출력을 표시하는 그리드 형식으로 출력을 얻으려면 어떻게 해야 합니까?
답변1
| Out-GridView
끝에 다음 을 추가하세요 .
Get-NetFirewallRule |
Where-Object {($_.Profiles -band [Microsoft.PowerShell.Cmdletization.GeneratedTypes.NetSecurity.Profile]::Domain) -or ($_.Profiles -eq [Microsoft.PowerShell.Cmdletization.GeneratedTypes.NetSecurity.Profile]::Any)} |
ForEach-Object {
$portFilter = Get-NetFirewallPortFilter -AssociatedNetFirewallRule $_
$_ | Select-Object -Property `
Name,
DisplayName,
DisplayGroup,
Profiles,
Direction,
@{n='Protocol'; e={$portFilter.Protocol}},
@{n='LocalPort'; e={$portFilter.LocalPort}},
@{n='RemotePort'; e={$portFilter.RemotePort}},
@{n='RemoteAddress'; e={(Get-NetFirewallAddressFilter -AssociatedNetFirewallRule $_).RemoteAddress}},
Enabled,
Profile,
Action
} | Out-GridView
다음과 같습니다: