Commit 90030416 authored by Viet Hoang's avatar Viet Hoang
Browse files

init the Scripts for Sitecore 9.1 installation

parent 61a956c5
Function Get-JavaVersions() {
$versions = '', 'Wow6432Node\' |
ForEach-Object {Get-ItemProperty -Path HKLM:\SOFTWARE\$($_)Microsoft\Windows\CurrentVersion\Uninstall\* |
Where-Object {($_.DisplayName -like '*Java *') -and (-not $_.SystemComponent)} |
Select-Object DisplayName, DisplayVersion, InstallLocation, @{n = 'Architecture'; e = {If ($_.PSParentPath -like '*Wow6432Node*') {'x86'} Else {'x64'}}}}
return $versions
}
Function Get-JavaInstallationPath
{
param (
[version] $toVersion
)
$versions_ = Get-JavaVersions
$foundRightVersion = $false
$JavaInstallPath = ""
foreach ($version_ in $versions_) {
try {
$version = New-Object System.Version($version_.DisplayVersion)
}
catch {
continue
}
if ($version.CompareTo($toVersion) -ge 0) {
$foundRightVersion = $true
$JavaInstallPath = $version_.InstallLocation
break;
}
}
if (-not $foundRightVersion) {
throw "Invalid Java version. Expected $JavaMinVersionRequired or above."
}
return $JavaInstallPath
}
Function Find-UpdateJAVAHOME
{
param (
[Version] $JavaMinVersionRequired
)
$JREPath = Get-JavaInstallationPath($JavaMinVersionRequired)
$jreVal_ = [Environment]::GetEnvironmentVariable("JAVA_HOME", [EnvironmentVariableTarget]::Machine)
if($jreVal_ -ne $JREPath)
{
Write-Host "Setting JAVA_HOME environment variable"
[Environment]::SetEnvironmentVariable("JAVA_HOME", $JREPath, [EnvironmentVariableTarget]::Machine)
# Fixed known issue: error finding keytool
$jreVal_ = $JREPath
}
return $jreVal_
}
Function Get-JavaKeytool
{
param (
[string] $JavaMinVersionRequired = "8.0.1510"
)
$RequiredVersion = New-Object System.Version($JavaMinVersionRequired)
try {
$jreVal = Find-UpdateJAVAHOME -JavaMinVersionRequired $RequiredVersion
$path = $jreVal + '\bin\keytool.exe'
if (Test-Path $path) {
$keytool_ = (Get-Command $path).Source
}
} catch {
$keytool_ = Read-Host "keytool.exe not on path. Enter path to keytool (found in JRE bin folder)"
}
if([string]::IsNullOrEmpty($keytool_) -or -not (Test-Path $keytool_)) {
throw "Keytool path was invalid."
}
return $keytool_
}
function downloadAndUnzipIfRequired
{
Param(
[string]$toolName,
[string]$toolFolder,
[string]$toolZip,
[string]$toolSourceFile,
[string]$installRoot
)
if(!(Test-Path -Path $toolFolder))
{
if(!(Test-Path -Path $toolZip))
{
Write-Host "Downloading $toolName..."
Start-BitsTransfer -Source $toolSourceFile -Destination $toolZip
}
Write-Host "Extracting $toolName to $toolFolder..."
Expand-Archive $toolZip -DestinationPath $installRoot
}
}
\ No newline at end of file
# Credit primarily to jermdavis for the original script
Param(
[string]$solrVersion = "7.2.1",
[string]$installFolder = "D:\solr",
[string]$solrPort = "8984",
[string]$solrHost = "localhost",
[bool]$solrSSL = $TRUE,
[string]$nssmVersion = "2.24",
[string]$keystoreSecret = "secret",
[string]$KeystoreFile = 'solr-ssl.keystore.jks',
[string]$SolrDomain = 'localhost',
[switch]$Clobber
)
$solrName = "solr-$solrVersion"
$solrRoot = "$installFolder\$solrName"
$nssmRoot = "$installFolder\nssm-$nssmVersion"
$solrPackage = "http://archive.apache.org/dist/lucene/solr/$solrVersion/$solrName.zip"
$nssmPackage = "http://nssm.cc/release/nssm-$nssmVersion.zip"
$downloadFolder =(Resolve-Path "\")
## Verify elevated
## https://superuser.com/questions/749243/detect-if-powershell-is-running-as-administrator
$elevated = [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")
if(!($elevated))
{
throw "In order to install services, please run this script elevated."
}
$JavaMinVersionRequired = "8.0.1510"
if (Get-Module("helper")) {
Remove-Module "helper"
}
Import-Module "$PSScriptRoot\helper.psm1"
$ErrorActionPreference = 'Stop'
# Ensure Java environment variable
try {
$keytool = (Get-Command 'keytool.exe').Source
} catch {
$keytool = Get-JavaKeytool -JavaMinVersionRequired $JavaMinVersionRequired
}
# download & extract the solr archive to the right folder
$solrZip = "$downloadFolder\$solrName.zip"
downloadAndUnzipIfRequired "Solr" $solrRoot $solrZip $solrPackage $installFolder
# download & extract the nssm archive to the right folder
$nssmZip = "$downloadFolder\nssm-$nssmVersion.zip"
downloadAndUnzipIfRequired "NSSM" $nssmRoot $nssmZip $nssmPackage $installFolder
### PARAM VALIDATION
if($keystoreSecret -ne 'secret') {
Write-Error 'The keystore password must be "secret", because Solr apparently ignores the parameter'
}
if((Test-Path $KeystoreFile)) {
if($Clobber) {
Write-Host "Removing $KeystoreFile..."
Remove-Item $KeystoreFile
} else {
$KeystorePath = Resolve-Path $KeystoreFile
Write-Error "Keystore file $KeystorePath already existed. To regenerate it, pass -Clobber."
}
}
$P12Path = [IO.Path]::ChangeExtension($KeystoreFile, 'p12')
if((Test-Path $P12Path)) {
if($Clobber) {
Write-Host "Removing $P12Path..."
Remove-Item $P12Path
} else {
$P12Path = Resolve-Path $P12Path
Write-Error "Keystore file $P12Path already existed. To regenerate it, pass -Clobber."
}
}
### DOING STUFF
Write-Host ''
Write-Host 'Generating JKS keystore...'
& $keytool -genkeypair -alias solr-ssl -keyalg RSA -keysize 2048 -keypass $keystoreSecret -storepass $keystoreSecret -validity 9999 -keystore $KeystoreFile -ext SAN=DNS:$SolrDomain,IP:127.0.0.1 -dname "CN=$SolrDomain, OU=Organizational Unit, O=Organization, L=Location, ST=State, C=Country"
Write-Host ''
Write-Host 'Generating .p12 to import to Windows...'
& $keytool -importkeystore -srckeystore $KeystoreFile -destkeystore $P12Path -srcstoretype jks -deststoretype pkcs12 -srcstorepass $keystoreSecret -deststorepass $keystoreSecret
Write-Host ''
Write-Host 'Trusting generated SSL certificate...'
$secureStringKeystorePassword = ConvertTo-SecureString -String $keystoreSecret -Force -AsPlainText
$root = Import-PfxCertificate -FilePath $P12Path -Password $secureStringKeystorePassword -CertStoreLocation Cert:\LocalMachine\Root
Write-Host 'SSL certificate is now locally trusted. (added as root CA)'
if(-not $KeystoreFile.EndsWith('solr-ssl.keystore.jks')) {
Write-Warning 'Your keystore file is not named "solr-ssl.keystore.jks"'
Write-Warning 'Solr requires this exact name, so make sure to rename it before use.'
}
$KeystorePath = Resolve-Path $KeystoreFile
Copy-Item $KeystorePath -Destination "$solrRoot\server\etc\solr-ssl.keystore.jks" -Force
# Update solr cfg to use keystore & right host name
if(Test-Path -Path "$solrRoot\bin\solr.in.cmd.old")
{
Write-Host "Resetting solr.in.cmd" -ForegroundColor Green
Remove-Item "$solrRoot\bin\solr.in.cmd"
Rename-Item -Path "$solrRoot\bin\solr.in.cmd.old" -NewName "$solrRoot\bin\solr.in.cmd"
}
Write-Host "Rewriting solr config"
$cfg = Get-Content "$solrRoot\bin\solr.in.cmd"
Rename-Item "$solrRoot\bin\solr.in.cmd" "$solrRoot\bin\solr.in.cmd.old"
$certStorePath = "etc/solr-ssl.keystore.jks"
$newCfg = $cfg | ForEach-Object { $_ -replace "REM set SOLR_SSL_KEY_STORE=etc/solr-ssl.keystore.jks", "set SOLR_SSL_KEY_STORE=$certStorePath" }
$newCfg = $newCfg | ForEach-Object { $_ -replace "REM set SOLR_SSL_KEY_STORE_PASSWORD=secret", "set SOLR_SSL_KEY_STORE_PASSWORD=$keystoreSecret" }
$newCfg = $newCfg | ForEach-Object { $_ -replace "REM set SOLR_SSL_TRUST_STORE=etc/solr-ssl.keystore.jks", "set SOLR_SSL_TRUST_STORE=$certStorePath" }
$newCfg = $newCfg | ForEach-Object { $_ -replace "REM set SOLR_SSL_TRUST_STORE_PASSWORD=secret", "set SOLR_SSL_TRUST_STORE_PASSWORD=$keystoreSecret" }
$newCfg = $newCfg | ForEach-Object { $_ -replace "REM set SOLR_HOST=192.168.1.1", "set SOLR_HOST=$solrHost" }
$newCfg | Set-Content "$solrRoot\bin\solr.in.cmd"
# install the service & runs
$svc = Get-Service "$solrName" -ErrorAction SilentlyContinue
if(!($svc))
{
Write-Host "Installing Solr service"
&"$installFolder\nssm-$nssmVersion\win64\nssm.exe" install "$solrName" "$solrRoot\bin\solr.cmd" "-f" "-p $solrPort"
$svc = Get-Service "$solrName" -ErrorAction SilentlyContinue
}
if($svc.Status -ne "Running")
{
Write-Host "Starting Solr service..."
Start-Service "$solrName"
}
elseif ($svc.Status -eq "Running")
{
Write-Host "Restarting Solr service..."
Restart-Service "$solrName"
}
Start-Sleep -s 5
# finally prove it's all working
$protocol = "http"
if($solrSSL)
{
$protocol = "https"
}
Invoke-Expression "start $($protocol)://$($solrHost):$solrPort/solr/#/"
Write-Host ''
Write-Host 'Done!' -ForegroundColor Green
\ No newline at end of file
$InstallDirectory = "D:\websites\"
#The prefix that will be used on the SOLR, Website, and Database instances.
$Prefix = "sc910"
# The root folder with the license file and the WDP files.
$SCInstallRoot = "D:\sc91_install"
# The name of the XConnect service.
$XConnectSiteName = "$prefix.xconnect.local"
# The Sitecore site instance name.
$SitecoreSiteName = "$prefix.local"
# The Identity Server site name.
$IdentityServerSiteName = "$prefix.identityserver.local"
# The path to the license file.
$LicenseFile = "$SCInstallRoot\license.xml"
# The URL of the Solr Server.
$SolrUrl = "https://localhost:8984/solr"
# The folder that Solr has been installed in.
$SolrRoot = "D:\Solr\solr-7.2.1"
# The name of the Solr Service.
$SolrService = "Solr-7.2.1"
# The DNS name or IP address of the SQL Instance.
$SqlServer = "DESKTOP-12HS4P0"
# A SQL user with sysadmin privileges.
$SqlAdminUser = "sa"
# The password for $SQLAdminUser.
$SqlAdminPassword = "Abcd1234"
# The path to the XConnect package to deploy.
$XConnectPackage = "$SCInstallRoot\Sitecore 9.1.0 rev. 001442 (OnPrem)_xp0xconnect.scwdp.zip"
# The path to the Sitecore package to deploy.
$SitecorePackage = "$SCInstallRoot\Sitecore 9.1.0 rev. 001442 (OnPrem)_single.scwdp.zip"
# The path to the Identity Server package to deploy.
$IdentityServerPackage = "$SCInstallRoot\Sitecore.IdentityServer 2.0.0 rev. 00151 (OnPrem)_identityserver.scwdp.zip"
# The Identity Server password recovery URL, this should be the URL of the CM instance.
$PasswordRecoveryUrl = "http://$SitecoreSiteName"
# The URL of the XconnectService.
$XConnectCollectionService = "https://$XConnectSiteName"
# The URL of the Identity Authority.
$SitecoreIdentityAuthority = "https://$IdentityServerSiteName"
# The random string key used for establishing a connection with the IdentityService.
$ClientSecret = "SIF-Default"
# A pipe-separated list of instances (URIs) that are allowed to log in through Sitecore Identity.
$AllowedCorsOrigins = "http://$SitecoreSiteName"
# Install XP0 via combined partials file.
$singleDeveloperParams = @{
Path = "$SCInstallRoot\XP0-SingleDeveloper.json"
InstallDirectory = $InstallDirectory
SqlServer = $SqlServer
SqlAdminUser = $SqlAdminUser
SqlAdminPassword = $SqlAdminPassword
SolrUrl = $SolrUrl
SolrRoot = $SolrRoot
SolrService = $SolrService
Prefix = $Prefix
XConnectCertificateName = $XConnectSiteName
IdentityServerCertificateName = $IdentityServerSiteName
IdentityServerSiteName = $IdentityServerSiteName
LicenseFile = $LicenseFile
XConnectPackage = $XConnectPackage
SitecorePackage = $SitecorePackage
IdentityServerPackage = $IdentityServerPackage
XConnectSiteName = $XConnectSiteName
SitecoreSitename = $SitecoreSiteName
PasswordRecoveryUrl = $PasswordRecoveryUrl
SitecoreIdentityAuthority = $SitecoreIdentityAuthority
XConnectCollectionService = $XConnectCollectionService
ClientSecret = $ClientSecret
AllowedCorsOrigins = $AllowedCorsOrigins
}
Push-Location $SCInstallRoot
Install-SitecoreConfiguration @singleDeveloperParams *>&1 | Tee-Object XP0-SingleDeveloper.log
Pop-Location
\ No newline at end of file
#define parameters
Param(
[string]$Prefix = "sc910",
[string]$SitecoreSiteName = "$Prefix.local",
[string]$SitecoreXConnect = "$($Prefix).xconnect.local",
[string]$SitecoreIdentityServer = "$($Prefix).identityserver.local",
[string]$InstallDirectory = "D:\websites\",
[string]$SolrService = "Solr-7.2.1",
[string]$PathToSolr = "D:\solr\Solr-7.2.1",
[string]$SqlServer = "DESKTOP-12HS4P0",
[string]$SqlAccount = "sa",
[string]$SqlPassword = "Abcd1234"
)
#Write-TaskHeader function modified from SIF
Function Write-TaskHeader {
param(
[Parameter(Mandatory=$true)]
[string]$TaskName,
[Parameter(Mandatory=$true)]
[string]$TaskType
)
function StringFormat {
param(
[int]$length,
[string]$value,
[string]$prefix = '',
[string]$postfix = '',
[switch]$padright
)
# wraps string in spaces so we reduce length by two
$length = $length - 2 #- $postfix.Length - $prefix.Length
if($value.Length -gt $length){
# Reduce to length - 4 for elipsis
$value = $value.Substring(0, $length - 4) + '...'
}
$value = " $value "
if($padright){
$value = $value.PadRight($length, '*')
} else {
$value = $value.PadLeft($length, '*')
}
return $prefix + $value + $postfix
}
$actualWidth = (Get-Host).UI.RawUI.BufferSize.Width
$width = $actualWidth - ($actualWidth % 2)
$half = $width / 2
$leftString = StringFormat -length $half -value $TaskName -prefix '[' -postfix ':'
$rightString = StringFormat -length $half -value $TaskType -postfix ']' -padright
$message = ($leftString + $rightString)
Write-Host ''
Write-Host $message -ForegroundColor 'Red'
}
Function Remove-Service{
[CmdletBinding()]
param(
[string]$serviceName
)
if(Get-Service "My Service" -ErrorAction SilentlyContinue){
sc.exe delete $serviceName
}
}
Function Remove-Website{
[CmdletBinding()]
param(
[string]$siteName
)
$appCmd = "C:\windows\system32\inetsrv\appcmd.exe"
& $appCmd delete site $siteName
}
Function Remove-AppPool{
[CmdletBinding()]
param(
[string]$appPoolName
)
$appCmd = "C:\windows\system32\inetsrv\appcmd.exe"
& $appCmd delete apppool $appPoolName
}
#stop windows services
Write-TaskHeader -TaskName "Windows services" -TaskType "Delete"
Write-Host "Deleting Windows services"
sc.exe delete $("$($Prefix).xconnect.local-MarketingAutomationService")
sc.exe delete $("$($Prefix).xconnect.local-IndexWorker")
sc.exe delete $("$($Prefix).xconnect.local-ProcessingEngineService")
Write-Host "Windows services deleted successfully"
#stop key windows processes
Write-TaskHeader -TaskName "Windows Processes" -TaskType "Stop"
Write-Host "Stopping windows processes"
Stop-Process -Name Xconnect* -Force -ErrorAction SilentlyContinue
Stop-Process -Name maengine -Force -ErrorAction SilentlyContinue
Write-Host "Windows processes stopped successfully"
#Stop Solr Service
Write-TaskHeader -TaskName "Solr Services" -TaskType "Stop"
Write-Host "Stopping solr service"
Stop-Service $SolrService -Force -ErrorAction stop
Write-Host "Solr service stopped successfully"
#Delete solr cores
Write-TaskHeader -TaskName "Solr Services" -TaskType "Delete Cores"
Write-Host "Deleting Solr Cores"
$pathToCores = "$pathToSolr\server\solr\$Prefix`_*" # escape the _ with `
Remove-Item $pathToCores -recurse -force -ErrorAction stop
Write-Host "Solr Cores $pathToCores deleted successfully"
#Remove Sites and App Pools from IIS
Write-TaskHeader -TaskName "Internet Information Services" -TaskType "Remove Websites"
Write-Host "deleting websites"
Write-Host "Deleting Website $SitecoreSiteName"
Remove-Website -siteName $SitecoreSiteName -ErrorAction stop
Write-Host "Deleting Website $SitecoreXConnect"
Remove-Website -siteName $SitecoreXConnect -ErrorAction stop
Write-Host "Deleting Website $SitecoreIdentityServer"
Remove-Website -siteName $SitecoreIdentityServer -ErrorAction stop
Write-Host "Websites deleted"
Write-TaskHeader -TaskName "Internet Information Services" -TaskType "Remove Application Pools"
Write-Host "Deleting application pools"
Write-Host "Deleting apppool $SitecoreSiteName"
Remove-AppPool -appPoolName $SitecoreSiteName -ErrorAction SilentlyContinue
Write-Host $("Deleting apppool $SitecoreXConnect")
Remove-AppPool -appPoolName $SitecoreXConnect -ErrorAction SilentlyContinue
Write-Host $("Deleting apppool $SitecoreIdentityServer")
Remove-AppPool -appPoolName $SitecoreIdentityServer -ErrorAction stop
Write-Host "Application pools deleted"
Write-TaskHeader -TaskName "Internet Information Services" -TaskType "Remove Folders"
#Remove website folders from wwwroot
Remove-Item $InstallDirectory\$SitecoreSiteName -recurse -force -ErrorAction SilentlyContinue
Remove-Item $InstallDirectory\$SitecoreXConnect -recurse -force -ErrorAction SilentlyContinue
Remove-Item $InstallDirectory\$SitecoreIdentityServer -recurse -force -ErrorAction SilentlyContinue
Write-Host "Websites removed from $InstallDirectory"
Write-TaskHeader -TaskName "SQL Server" -TaskType "Drop Databases"
#Drop databases from SQL
Write-Host "Dropping databases from SQL server"
push-location
import-module sqlps
$sqlPrefix = $("DROP DATABASE IF EXISTS [$($Prefix)")
Write-Host $("Dropping database $($Prefix)_Core")
$corePrefix = $("$($sqlPrefix)_Core]")
Write-Host $("Query: $($corePrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $corePrefix -ErrorAction stop
Write-Host $("Dropping database $($Prefix)_ExperienceForms")
$xfPrefix = $("$($sqlPrefix)_ExperienceForms]")
Write-Host $("Query: $($xfPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $xfPrefix -ErrorAction stop
Write-Host $("Dropping database $($Prefix)_MarketingAutomation")
$maPrefix = $("$($sqlPrefix)_MarketingAutomation]")
Write-Host $("Query: $($maPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $maPrefix -ErrorAction SilentlyContinue
Write-Host $("Dropping database $($Prefix)_Master")
$masterPrefix = $("$($sqlPrefix)_Master]")
Write-Host $("Query: $($masterPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $masterPrefix -ErrorAction SilentlyContinue
Write-Host $("Dropping database $($Prefix)_Processing.Pools")
$ppPrefix = $("$($sqlPrefix)_Processing.Pools]")
Write-Host $("Query: $($ppPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $ppPrefix -ErrorAction SilentlyContinue
Write-Host $("Dropping database $($Prefix)_Processing.Tasks")
$ptPrefix = $("$($sqlPrefix)_Processing.Tasks]")
Write-Host $("Query: $($ptPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $ptPrefix -ErrorAction SilentlyContinue
Write-Host $("Dropping database $($Prefix)_ReferenceData")
$rdPrefix = $("$($sqlPrefix)_ReferenceData]")
Write-Host $("Query: $($rdPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $rdPrefix -ErrorAction SilentlyContinue
Write-Host $("Dropping database $($Prefix)_Reporting")
$repPrefix = $("$($sqlPrefix)_Reporting]")
Write-Host $("Query: $($repPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $repPrefix -ErrorAction SilentlyContinue
Write-Host $("Dropping database $($Prefix)_Web")
$webPrefix = $("$($sqlPrefix)_Web]")
Write-Host $("Query: $($webPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $webPrefix -ErrorAction SilentlyContinue
Write-Host $("Dropping database $($Prefix)_Xdb.Collection.Shard0")
$xbs0Prefix = $("$($sqlPrefix)_Xdb.Collection.Shard0]")
Write-Host $("Query: $($xbs0Prefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $xbs0Prefix -ErrorAction SilentlyContinue
Write-Host $("Dropping database $($Prefix)_Xdb.Collection.Shard1")
$xbs1Prefix = $("$($sqlPrefix)_Xdb.Collection.Shard1]")
Write-Host $("Query: $($xbs1Prefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $xbs1Prefix -ErrorAction SilentlyContinue
Write-Host $("Dropping database $($Prefix)_Xdb.Collection.ShardMapManager")
$xbsmPrefix = $("$($sqlPrefix)_Xdb.Collection.ShardMapManager]")
Write-Host $("Query: $($xbsmPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $xbsmPrefix -ErrorAction SilentlyContinue
Write-Host $("Dropping database $($Prefix)_EXM.Master")
$exmmasterPrefix = $("$($sqlPrefix)_EXM.Master]")
Write-Host $("Query: $($exmmasterPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $exmmasterPrefix -ErrorAction SilentlyContinue
Write-Host $("Dropping database $($Prefix)_Messaging")
$messagingPrefix = $("$($sqlPrefix)_Messaging]")
Write-Host $("Query: $($messagingPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $messagingPrefix -ErrorAction SilentlyContinue
Write-Host $("Dropping database $($Prefix)_ProcessingEngineStorage")
$messagingPrefix = $("$($sqlPrefix)_ProcessingEngineStorage]")
Write-Host $("Query: $($messagingPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $messagingPrefix -ErrorAction SilentlyContinue
Write-Host $("Dropping database $($Prefix)_ProcessingEngineTasks")
$messagingPrefix = $("$($sqlPrefix)_ProcessingEngineTasks]")
Write-Host $("Query: $($messagingPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $messagingPrefix -ErrorAction SilentlyContinue
Write-Host "Databases dropped successfully"
pop-location
#Remove Host Entries
Write-TaskHeader -TaskName "Host Entries" -TaskType "Remove"
Install-Module PsHosts