diff --git a/images/win/scripts/Installers/Install-MongoDB.ps1 b/images/win/scripts/Installers/Install-MongoDB.ps1
index d56382307..245e5b98f 100644
--- a/images/win/scripts/Installers/Install-MongoDB.ps1
+++ b/images/win/scripts/Installers/Install-MongoDB.ps1
@@ -3,6 +3,7 @@
## Desc: Install MongoDB
####################################################################################
-choco install mongodb
-
-Add-MachinePathItem "$($env:SystemDrive)\Program Files\MongoDB\Server\4.2\bin"
+Choco-Install -PackageName mongodb
+$mongoPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'mongodb'").PathName
+$mongoBin = Split-Path -Path $mongoPath.split('"')[1]
+Add-MachinePathItem "$mongoBin"
diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/win/scripts/Installers/Install-PostgreSQL.ps1
index 2e6bc373d..c0765c654 100644
--- a/images/win/scripts/Installers/Install-PostgreSQL.ps1
+++ b/images/win/scripts/Installers/Install-PostgreSQL.ps1
@@ -1,22 +1,19 @@
$ErrorActionPreference = "Stop"
-Import-Module -Name ImageHelpers
-
#Define user and password for PostgreSQL database
-$postgresusr="postgres"
-$postgrespwd="root"
+$pgUser = "postgres"
+$pgPwd = "root"
#Prepare environment variable for validation
-Set-SystemVariable -SystemVariable PGUSER -Value $postgresusr
-Set-SystemVariable -SystemVariable PGPASSWORD -Value $postgrespwd
-#Install latest PostgreSQL
+Set-SystemVariable -SystemVariable PGUSER -Value $pgUser
+Set-SystemVariable -SystemVariable PGPASSWORD -Value $pgPwd
-cinst postgresql --params "/Password:$postgrespwd" --params-global --debug --verbose
+#Install latest PostgreSQL
+Choco-Install -PackageName postgresql -ArgumentList "--params", "/Password:$pgPwd", "--params-global", "--debug", "--verbose"
#Get Path to pg_ctl.exe
-$paths = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName
+$pgPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName
#Parse output of command above to obtain pure path
-$pgbin = $paths.split('"')[1].replace("\pg_ctl.exe", "")
-#Added PostgreSQL bin path into PATH variable.
-Add-MachinePathItem $pgbin
-
+$pgBin = Split-Path -Path $pgPath.split('"')[1]
+#Added PostgreSQL bin path into PATH variable
+Add-MachinePathItem $pgBin
diff --git a/images/win/scripts/Installers/Validate-MongoDB.ps1 b/images/win/scripts/Installers/Validate-MongoDB.ps1
index e0580b543..517f824cb 100644
--- a/images/win/scripts/Installers/Validate-MongoDB.ps1
+++ b/images/win/scripts/Installers/Validate-MongoDB.ps1
@@ -3,10 +3,9 @@
## Desc: Validate MongoDB
################################################################################
-$command = Get-Command -Name 'mongod'
-if($command)
+if (Get-Command -Name 'mongod')
{
- Write-Host "mongod is on path"
+ Write-Host 'mongod is on path'
}
else
{
@@ -14,25 +13,12 @@ else
exit 1
}
-$command = Get-Command -Name 'mongo'
-if($command)
+if (Get-Command -Name 'mongo')
{
- Write-Host "mongo is on path"
+ Write-Host 'mongo is on path'
}
else
{
Write-Host 'mongo not on path'
exit 1
}
-
-# Adding description of the software to Markdown
-$SoftwareName = "MongoDB"
-$version = $command.Version.ToString();
-
-$Description = @"
-_Version:_ $version
-_Environment:_
-* PATH: contains location of mongo.exe and mongod.exe
-"@
-
-Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description
diff --git a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 b/images/win/scripts/Installers/Validate-PostgreSQL.ps1
index bfd2f0f05..14cdc2981 100644
--- a/images/win/scripts/Installers/Validate-PostgreSQL.ps1
+++ b/images/win/scripts/Installers/Validate-PostgreSQL.ps1
@@ -1,35 +1,17 @@
-$PGUSER="postgres"
-function Validate-PostgreSQL {
- $pgready = Start-Process -FilePath pg_isready -Wait -PassThru
- $exitCode = $pgready.ExitCode
- if ($exitCode -eq 0)
- {
- Write-Host -Object "PostgreSQL has been successfully installed."
- }
- else
- {
- Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode"
- exit $exitCode
- }
+$pgReady = Start-Process -FilePath pg_isready -Wait -PassThru
+$exitCode = $pgReady.ExitCode
+
+if ($exitCode -eq 0)
+{
+ Write-Host -Object "PostgreSQL has been successfully installed."
+}
+else
+{
+ Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode"
+ exit $exitCode
}
-$paths = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName
-$pgservice = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").Name
-$pgroot = $paths.split('"')[1].replace("\bin\pg_ctl.exe", "")
-$psqlVersion = pg_config --version | Out-String
-Validate-PostgreSQL
-
-# Adding description of the software to Markdown
-$SoftwareName = "PostgreSQL"
-$Description = @"
-_Version:_ $psqlVersion
-_Default Path:_ $pgroot
-_User:_ $env:PGUSER
-_Password:_ $env:PGPASSWORD
-"@
-
-Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description
-
#Stop and disable PostgreSQL service
-Stop-Service -Name $pgservice
-Set-Service $pgservice -StartupType Disabled
+$pgService = Get-Service -Name postgresql*
+Stop-Service -InputObject $pgService
+Set-Service -InputObject $pgService -StartupType Disabled
diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Databases.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Databases.psm1
new file mode 100644
index 000000000..ed16fab42
--- /dev/null
+++ b/images/win/scripts/SoftwareReport/SoftwareReport.Databases.psm1
@@ -0,0 +1,41 @@
+function Get-PostgreSQLMarkdown
+{
+ $name = "PostgreSQL"
+ $pgService = Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'"
+ $pgPath = $pgService.PathName
+ $pgRoot = $pgPath.split('"')[1].replace("\bin\pg_ctl.exe", "")
+ $pgVersion = (pg_config --version).split()[1].Trim()
+ $content = [PSCustomObject]@{
+ Version = $pgVersion
+ UserName = $env:PGUSER
+ Password = $env:PGPASSWORD
+ Path = $pgRoot
+ ServiceName = $pgService.Name
+ ServiceStatus = $pgService.State
+ ServiceStartType = $pgService.StartMode
+ } | New-MDTable
+
+ Build-MarkdownElement -Head $name -Content $content
+}
+
+function Get-MongoDBMarkdown
+{
+ $name = "MongoDB"
+ $mongoService = Get-Service -Name $name
+ $mongoVersion = (Get-Command -Name 'mongo').Version.ToString()
+ $content = [PSCustomObject]@{
+ Version = $mongoVersion
+ ServiceName = $name
+ ServiceStatus = $mongoService.Status
+ ServiceStartType = $mongoService.StartType
+ } | New-MDTable
+ Build-MarkdownElement -Head $name -Content $content
+}
+
+function Build-DatabasesMarkdown
+{
+ $markdown = ""
+ $markdown += Get-PostgreSQLMarkdown
+ $markdown += Get-MongoDBMarkdown
+ $markdown
+}
\ No newline at end of file
diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1
index a7617a4c4..903d39476 100644
--- a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1
+++ b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1
@@ -2,13 +2,14 @@
Install-Module MarkdownPS -Force -Scope AllUsers
Import-Module MarkdownPS
-Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Helpers.psm1") -DisableNameChecking
-Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Common.psm1") -DisableNameChecking
-Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Tools.psm1") -DisableNameChecking
+Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Android.psm1") -DisableNameChecking
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Browsers.psm1") -DisableNameChecking
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.CachedTools.psm1") -DisableNameChecking
+Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Common.psm1") -DisableNameChecking
+Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Databases.psm1") -DisableNameChecking
+Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Helpers.psm1") -DisableNameChecking
+Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Tools.psm1") -DisableNameChecking
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.VisualStudio.psm1") -DisableNameChecking
-Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Android.psm1") -DisableNameChecking
$markdown = ""
@@ -127,6 +128,10 @@ $markdown += New-MDHeader "Cached Tools" -Level 3
$markdown += (Build-CachedToolsMarkdown)
$markdown += New-MDNewLine
+$markdown += New-MDHeader "Databases" -Level 3
+$markdown += Build-DatabasesMarkdown
+$markdown += New-MDNewLine
+
$vs = Get-VisualStudioVersion
$markdown += New-MDHeader "$($vs.Name)" -Level 3
$markdown += $vs | New-MDTable