AsBuiltReport / AsBuiltReport.Fortinet.FortiGate

Repository for AsBuiltReport Fortinet FortiGate module
MIT License
37 stars 12 forks source link

Port specification + Style, not working #37

Closed connorhess closed 1 year ago

connorhess commented 1 year ago

Bug description

Hi, we are trying to customize the color's and specify a port for the as built, but it keeps failing.

i specified the port, as it stood in the AsBuilt.json

{ "Report": { "Name": "Fortinet FortiGate As Built Report", "Version": "1.0", "Status": "Released", "ShowCoverPageImage": true, "ShowTableOfContents": true, "ShowHeaderFooter": true, "ShowTableCaptions": true }, "Options": { "Port": 44310, "VDOM": "" }, "InfoLevel": { "_comment_": "0 = Disabled, 1 = Enabled / Summary, 2 = Adv Summary", "FortiCare": 1, "System": 1, "Route": 1, "Firewall": 1, "User": 2, "VPNIPsec": 2, "VPNSSL": 2 }, "HealthCheck": {}, "Port": 44310 }

and includded it in this command New-AsBuiltReport -Report Fortinet.FortiGate -Target $Server -Username $Username -Password $Password_un -Format Word -OutputFolderPath 'C:\AsBuilt\' -Timestamp -AsBuiltConfigFilePath 'C:\AsBuilt\AsBuilt.json'

but it fails to connect.

this is the bat file we are using, so you can see we are connecting, (everything works on the default port)

`$Username = 'username' $Password_un = 'password' $Server = '12.12.12.12' $Port = 44310

$password = ConvertTo-SecureString $Password_un -AsPlainText -Force

netsh interface portproxy add v4tov4 listenport = 443 connectport = $Port connectaddress = $Server

Connect-FGT -Server $Server -Username $Username -Password $password -Port $Port -SkipCertificateCheck

New-AsBuiltReport -Report Fortinet.FortiGate -Target $Server -Username $Username -Password $Password_un -Format Word -OutputFolderPath 'C:\AsBuilt\' -Timestamp -AsBuiltConfigFilePath 'C:\AsBuilt\AsBuilt.json' `

Command-line input

New-AsBuiltReport -Report Fortinet.FortiGate -Target $Server -Username $Username -Password $Password_un -Format Word -OutputFolderPath 'C:\AsBuilt\' -Timestamp -AsBuiltConfigFilePath 'C:\AsBuilt\AsBuilt.json

Steps to reproduce

  1. setup a firewall on port 44310
  2. generate the report on that port

Expected behaviour

connection gets made, and report gets generated

Screenshots

No response

Operating System

Windows

PowerShell Version

Name Value


PSVersion 5.1.22621.1778 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22621.1778 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

PowerShell Modules

Name Version


AsBuiltReport.Core 1.3.0 AsBuiltReport.Fortinet.FortiGate 0.2.0 PowerFGT 0.7.0 PScribo 0.10.0

Additional Context

No response

Before submitting

alagoutte commented 1 year ago

Hi connor,

You need to use

-ReportConfigFilePath 'C:\AsBuilt\AsBuilt.json'

and not

-AsBuiltConfigFilePath 'C:\AsBuilt\AsBuilt.json'

I check the README.md and it is good

you can use -verbose to look what path/file it is issued...

[...]
VERBOSE: Populating RepositorySourceLocation property for module AsBuiltReport.Fortinet.FortiGate.
VERBOSE: Loading module from path 'C:\Users\Administrator\Documents\PowerShell\Modules\AsBuiltReport.Fortinet.FortiGate\0.2.0\AsBuiltReport.Fortinet.FortiGate.psm1'.
VERBOSE: Loading AsBuiltReport.Fortinet.FortiGate report configuration file from path 'C:\Users\Administrator\Documents\forti\asbuild.forti.json'.
VERBOSE: Setting report filename to 'Fortinet FortiGate As Built Report - 2023-06-26_17.45.57'.
VERBOSE: [ 17:45:57:503 ] [ Document ] - Document 'Fortinet FortiGate As Built Report - 2023-06-26_17.45.57' processing started.
VERBOSE: [ 17:45:57:528 ] [ Document ] - Executing report style script from path 'C:\Users\Administrator\Documents\PowerShell\Modules\AsBuiltReport.Fortinet.FortiGate\0.2.0\AsBuiltReport.Fortinet.FortiGate.Style.ps1'.
[...]
connorhess commented 1 year ago

I will check at work tomorrow, if this is the issue, thanks, however very unlikely the only issue. 3 guys tried individually.

Sorry for any inconvenience if this was the issue. Will get back to you tomorrow.

alagoutte commented 1 year ago

I will check at work tomorrow, if this is the issue, thanks, however very unlikely the only issue. 3 guys tried individually.

Sorry for any inconvenience if this was the issue. Will get back to you tomorrow.

Sure, no problem!

connorhess commented 1 year ago

thanks, that worked, is there another place with documentation that we could have missed?, maybe it is a good idea to specify that you use that property for port specification.

I found the miscommunication issue with the documentation (AsBuiltReport.Core) that we had. In the readme there is an example block that says the following.

1. 
# Generate a VMware vSphere As Built report in HTML & Word formats. Perform a health check to highlight particular issues which exist within the Vmware vSphere environment. Save the report to the 'H:\Documents\' folder.
New-AsBuiltReport -Report 'VMware.vSphere' -Target '192.168.1.100' -Username 'admin' -Password 'admin' -Format HTML,Word -EnableHealthCheck -OutputFolderPath 'H:\Documents\'

2. 
# Generate a Nutanix Prism Element As Built Report using specified username and password credentials. Specify the report configuration file to be used. Export report to Text, HTML & DOCX formats. Use the default report style. Save the report to the '/Users/Tim/Documents' folder. Display verbose messages to the console.
New-AsBuiltReport -Report 'Nutanix.PrismElement' -Target 'prism.nutanix.local' -Username 'demo' -Password 'demo' -Format Text,Html,Word -OutputFolderPath '/Users/Tim/Documents' -ReportConfigFilePath '/Users/Tim/AsBuiltReport/AsBuiltReport.Nutanix.PrismElement.json' -Verbose

3. 
# Generate a Pure Storage FlashArray As Built Report in Text format and append a timestamp to the filename. Use stored credentials for authentication. Use the default Pure Storage report style. Save the reports to the 'H:\Documents' folder.
$Credentials = Get-Credential
New-AsBuiltReport -Report 'PureStorage.FlashArray' -Target '192.168.1.100' -Credential $Credentials -Format Text -Timestamp -OutputFolderPath 'H:\Documents\'

4. 
# The following creates a Cisco UCS Manager As Built report in default format (Word) with a customised style.
New-AsBuiltReport -Report 'Cisco.UCSManager' -Target '192.168.1.100' -Username 'admin' -Password 'admin' -StyleFilePath 'C:\scripts\ACME.ps1' -OutputFolderPath 'H:\Documents\'

5. 
# The following creates a Nutanix Prism Element As Built report in HTML format, with a custom filename.
New-AsBuiltReport -Report 'Nutanix.PrismElement' -Target '192.168.1.100' -Username 'admin' -Password 'admin' -Format HTML -AsBuiltConfigFilePath 'C:\scripts\asbuilt.json' -OutputFolderPath 'H:\Documents\' -Filename 'My Nutanix Configuration'

when looking in the AsBuilt.json that gets generated on the when installing, it specified the port. when we looked at the example at number 5, it shows -AsBuiltConfigFilePath 'C:\scripts\asbuilt.json'

To us this meant that we need to use -AsBuiltConfigFilePath. it might be a good idea to switch the file names between number 2 and 5.

I will put in a pull request to address this, as a thank you.

connorhess commented 1 year ago

As a side note, is there a way to add extra stuff to the word document outbut, where and how is the template defined?

alagoutte commented 1 year ago

As a side note, is there a way to add extra stuff to the word document outbut, where and how is the template defined?

the module use PSScribo, you can add what do you want... (but there is not option for this...)

tpcarman commented 1 year ago

@connorhess It is possible to apply some customisation to the report by creating a custom style. You may include additional information within your custom style script to add sections/tables/text before the generated report information. However, if you wish to include additional information within or after the generated report information, this would need to be added manually. You can find some sample report styles here.

connorhess commented 1 year ago

ok thanks, needed to add a signature line at the end.