-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreenOS Port Groups
38 lines (30 loc) · 1.24 KB
/
ScreenOS Port Groups
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$PortObjectGroups = @()
$items = @()
(Get-Content .\SCH-NS-FW-1_TECH.txt | Select-String '^set group service\s".+?"\s+add\s+') | ForEach-Object {
$i = $_
$GroupName = $i -replace '^set\s+group\s+service\s+"(.+?)"\s+add.*','$1'
$GroupName = $GroupName -replace '(\/|\\)','_'
$MemberName = $i -replace '^set\s+group\s+service\s+".+?"\s+add\s+"(.+?)"','$1'
$MemberName = $MemberName -replace '(\/|\\)','_'
$item = New-Object psobject
$item | Add-Member -MemberType NoteProperty -Name GroupName -Value $GroupName
$item | Add-Member -MemberType NoteProperty -Name MemberName -Value $MemberName
$items += $item
}
$Groups = @()
$unique = $items | Select-Object GroupName -Unique
$unique | foreach {
$uGroup = $items | Where-Object -Property GroupName -EQ -Value $_.GroupName
$pObject = @()
$uGroup | foreach {
$Member = $_.MemberName
$pObject = "$pObject$Member,"
}
$pObject = $pObject -replace ',$',''
$Group = New-Object psobject
$Group | Add-Member -MemberType NoteProperty -Name Name -Value $_.GroupName
$Group | Add-Member -MemberType NoteProperty -Name Objects -Value $pObject
$Groups += $Group
}
$Groups
#| Export-Csv -NoClobber -NoTypeInformation -Path .\netgroups2.csv