Files

43 lines
1.6 KiB
PowerShell
Raw Permalink Normal View History

2020-06-02 17:52:54 +05:00
####################################################################################
## File: Install-MongoDB.ps1
## Desc: Install MongoDB
####################################################################################
# Install mongodb package
$toolsetContent = Get-ToolsetContent
$toolsetVersion = $toolsetContent.mongodb.version
2023-12-04 10:50:53 +01:00
$getMongoReleases = Invoke-WebRequest -Uri "mongodb.com/docs/manual/release-notes/$toolsetVersion/" -UseBasicParsing
$targetReleases = $getMongoReleases.Links.href | Where-Object { $_ -like "#$toolsetVersion*---*" }
$minorVersions = @()
foreach ($release in $targetReleases) {
if ($release -notlike "*upcoming*") {
2023-12-04 10:50:53 +01:00
$pattern = '\d+\.\d+\.\d+'
$version = $release | Select-String -Pattern $pattern -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }
$minorVersions += $version
}
2023-12-04 10:50:53 +01:00
}
$latestVersion = $minorVersions[0]
Install-Binary `
-Url "https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-$latestVersion-signed.msi" `
2023-12-04 10:50:53 +01:00
-ExtraInstallArgs @('TARGETDIR=C:\PROGRA~1\MongoDB ADDLOCAL=ALL') `
-ExpectedSignature $toolsetContent.mongodb.signature
# Add mongodb to the PATH
2023-11-23 18:08:20 +01:00
$mongoPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'mongodb'").PathName
$mongoBin = Split-Path -Path $mongoPath.split('"')[1]
Add-MachinePathItem "$mongoBin"
2020-07-09 10:53:29 +03:00
2022-08-08 15:55:18 +02:00
# Wait for mongodb service running
2023-11-23 18:08:20 +01:00
$mongodbService = Get-Service "mongodb"
$mongodbService.WaitForStatus('Running', '00:01:00')
2022-08-08 15:55:18 +02:00
# Stop and disable mongodb service
2023-11-23 18:08:20 +01:00
Stop-Service $mongodbService
$mongodbService | Set-Service -StartupType Disabled
Invoke-PesterTests -TestFile "Databases" -TestName "MongoDB"