[Windows] Disable mongodb service by default (#6023)

* Disable mongodb service by default

* Add ErrorAction Ignore
This commit is contained in:
Aleksandr Chebotov
2022-08-05 20:50:37 +02:00
committed by GitHub
parent 58ba4559eb
commit f1bb031e43
2 changed files with 34 additions and 7 deletions

View File

@@ -3,11 +3,19 @@
## Desc: Install MongoDB
####################################################################################
# Install mongodb package
$toolsetVersion = (Get-ToolsetContent).mongodb.version
$latestChocoPackage = Get-LatestChocoPackageVersion -TargetVersion $toolsetVersion -PackageName "mongodb"
Choco-Install -PackageName mongodb -ArgumentList "--version=$latestChocoPackage"
$mongoPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'mongodb'").PathName
# Add mongodb to the PATH
$mongodbService = "mongodb"
$mongoPath = (Get-CimInstance Win32_Service -Filter "Name LIKE '$mongodbService'").PathName
$mongoBin = Split-Path -Path $mongoPath.split('"')[1]
Add-MachinePathItem "$mongoBin"
# Stop and disable mongodb service
Stop-Service -Name $mongodbService
Set-Service $mongodbService -StartupType Disabled
Invoke-PesterTests -TestFile "Databases" -TestName "MongoDB"