Files
runner-images/images/win/scripts/SoftwareReport/SoftwareReport.Databases.psm1
Maxim Lobanov 0f6fba462a Move CLI tests to the separate test file on Windows (#1363)
* move cli tests to the separate file

* switch install scripts

* unify CLI names
2020-08-06 11:27:58 +03:00

44 lines
1.7 KiB
PowerShell

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", "")
$env:Path += ";${env:PGBIN}"
$pgVersion = (postgres --version).split()[2].Trim()
$content = @(
[PSCustomObject]@{ Property = "ServiceName"; Value = $pgService.Name },
[PSCustomObject]@{ Property = "Version"; Value = $pgVersion },
[PSCustomObject]@{ Property = "ServiceStatus"; Value = $pgService.State },
[PSCustomObject]@{ Property = "ServiceStartType"; Value = $pgService.StartMode },
[PSCustomObject]@{ Property = "EnvironmentVariables"; Value = "`PGBIN=$env:PGBIN` <br> `PGDATA=$env:PGDATA` <br> `PGROOT=$env:PGROOT` " },
[PSCustomObject]@{ Property = "Path"; Value = $pgRoot },
[PSCustomObject]@{ Property = "UserName"; Value = $env:PGUSER },
[PSCustomObject]@{ Property = "Password"; Value = $env:PGPASSWORD }
) | 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
}