ps/Modules/Alkami.PowerShell.Configuration/Public/Test-IsServiceFabricServer.ps1

36 lines
778 B
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
Function Test-IsServiceFabricServer {
<#
.SYNOPSIS
Used to determine if the current server is a Service Fabric server.
#>
[CmdletBinding()]
[OutputType([bool])]
param(
)
$serverRole = Get-ServerRoleEnvironmentalVariable
# Check Environmental Variables first
if ($serverRole -eq "fabric") {
return $true
} elseif ($serverRole -match ("^(web|app|microservice)$")) {
return $false
}
# Then let's check the server name
if ($env:ComputerName.StartsWith("FAB")) {
return $true;
}
# If all else fails, check the alk:role tag if this is an AWS instance
if ((Test-IsAws) -and ((Get-CurrentInstanceTags "alk:role" -ValueOnly) -eq "app:fab")) {
return $true
}
return $false
}