Update Deploy-ZabbixAgent2.ps1
Modify Regex pattern to determine server type
This commit is contained in:
@@ -49,18 +49,23 @@ else {
|
||||
$osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
|
||||
$Hostname = $env:COMPUTERNAME
|
||||
|
||||
# Workstations
|
||||
if ($osInfo.ProductType -eq 1) {
|
||||
$Role = "Workstation"
|
||||
}
|
||||
elseif ($Hostname -match '-ss\d*') {
|
||||
# Primary: SQL servers (e.g., EHPS-SS19L, EHTS-SS16A, BI-SS22B)
|
||||
elseif ($Hostname -match '-ss\d{2}[a-z]?') {
|
||||
$Role = "SQL"
|
||||
}
|
||||
# Primary: Application servers (e.g., EHTS-APP38, BI-APP02)
|
||||
elseif ($Hostname -match '-app\d*') {
|
||||
$Role = "Application"
|
||||
}
|
||||
# Secondary Fallback: Running standalone default MSSQLSERVER instance on non-standard naming
|
||||
elseif (Get-Service -Name "MSSQLSERVER" -ErrorAction SilentlyContinue | Where-Object { $_.Status -eq "Running" }) {
|
||||
$Role = "SQL"
|
||||
}
|
||||
# Default: Member servers, DCs, and general workloads
|
||||
else {
|
||||
$Role = "Application"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user