function Test-IsNagServer { <# .SYNOPSIS Tests if the specified server is the designated Nag server for this pod. .PARAMETER server Server to test #> param( [ValidateNotNullOrEmpty()] [Alias("ComputerName")] [string]$Server = "localhost" ) # Set the path where the nag config file lives. $orbPath = Get-OrbPath $nagConfigFilepath = Join-Path $orbPath "\Nag\Alkami.App.Nag.Host.Service.exe.config" if ((![string]::IsNullOrWhiteSpace($Server)) -and ($Server -ne "localhost")) { $nagAppConfigPath = Get-UncPath -filePath $nagConfigFilepath -ComputerName $Server } else { $nagAppConfigPath = $nagConfigFilepath } # blatant theft er "borrowing": https://stackoverflow.com/a/27485038/3691973 # Yes, it's overkill. But it's concise. $slaveNodeValue = Get-AppSetting -filePath $nagAppConfigPath -appSettingKey "Nag.IsSlaveNode" $isSlaveNode = switch ($slaveNodeValue) { { $_ -eq 1 -or $_ -eq "True" } { $true } default { $false } } return (!$isSlaveNode -and (Test-IsNagRunning -Server $Server)) }