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
|
$osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
|
||||||
$Hostname = $env:COMPUTERNAME
|
$Hostname = $env:COMPUTERNAME
|
||||||
|
|
||||||
|
# Workstations
|
||||||
if ($osInfo.ProductType -eq 1) {
|
if ($osInfo.ProductType -eq 1) {
|
||||||
$Role = "Workstation"
|
$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"
|
$Role = "SQL"
|
||||||
}
|
}
|
||||||
|
# Primary: Application servers (e.g., EHTS-APP38, BI-APP02)
|
||||||
elseif ($Hostname -match '-app\d*') {
|
elseif ($Hostname -match '-app\d*') {
|
||||||
$Role = "Application"
|
$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" }) {
|
elseif (Get-Service -Name "MSSQLSERVER" -ErrorAction SilentlyContinue | Where-Object { $_.Status -eq "Running" }) {
|
||||||
$Role = "SQL"
|
$Role = "SQL"
|
||||||
}
|
}
|
||||||
|
# Default: Member servers, DCs, and general workloads
|
||||||
else {
|
else {
|
||||||
$Role = "Application"
|
$Role = "Application"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user