forked from skippernl/Fortigate2Excel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDocument-All.ps1
53 lines (50 loc) · 3.46 KB
/
Document-All.ps1
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<#
.SYNOPSIS
Fortigate2Excel parses the configuration from a FortiGate device into a Excel file.
.DESCRIPTION
The Fortigate2Excel reads a FortiGate config file and pulls out the configuration for each VDOM in the file into excel.
.PARAMETER SrcDir
[REQUIRED] This is the path to the FortiGate config/credential files
Optional switches are explained in the Fortigate2Excel script
.NOTES
Author: Xander Angenent (@XaAng70)
Idea: Drew Hjelm (@drewhjelm) (creates csv of ruleset only)
Last Modified: 2020/11/05
#>
Param
(
[Parameter(Mandatory = $true)]
$SrcDir,
[switch]$SkipFilter = $false,
[switch]$SkipFortiISDB = $false,
[switch]$SkipTimeZone = $false
)
Function CreateFiles ($ConfigFilesArray) {
Foreach ( $ConfigFile in $ConfigFilesArray ) {
$PSArgument = $BaseArgumentList
$PSArgument += "-FortigateConfig '$($ConfigFile.FullName)'"
Invoke-Expression ".\Fortigate2Excel.ps1 $PSArgument"
}
}
$BaseArgumentList = @()
$PSArgument = @()
if ($SkipFilter) { $BaseArgumentList += "-Skipfilter" }
if ($SkipFortiISDB) { $BaseArgumentList += "-SkipFortiISDB" }
if ($SkipTimeZone) { $BaseArgumentList += "-SkipTimeZone" }
#Get All *.conf Files
if (!(Test-Path $SrcDir)) {
Write-Output "Path not found stopping script."
exit 1
}
$GetConfigFiles = $SrcDir + "\" + "*.conf"
$ConfigFiles = Get-ChildItem $GetConfigFiles | Sort-Object Name
If ($ConfigFiles) { CreateFiles $ConfigFiles }
else {
Write-Output "No config (*.conf) files found."
}
$GetConfigFiles = $SrcDir + "\" + "*.cred"
$ConfigFiles = Get-ChildItem $GetConfigFiles | Sort-Object Name
If ($ConfigFiles) { CreateFiles $ConfigFiles }
else {
Write-Output "No credential (*.cred) files found."
}