ps/Modules/Alkami.DevOps.TeamCity/Public/Test-TeamCityComputerIsAvailable.ps1
2023-05-30 22:51:22 -07:00

35 lines
1.0 KiB
PowerShell

function Test-TeamCityComputerIsAvailable {
<#
.SYNOPSIS
Test that given computer(s) are on and able to be connected to
.PARAMETER ComputerName
[string] Computer(s) to connect to. Assumes .fh.local domain
.PARAMETER Type
Optional Parameter. Type of TeamCity host(s) to return: All, Server(s), or Agent(s)
#>
[CmdletBinding()]
[OutputType([Object])]
param (
[Parameter(Mandatory = $false)]
[string[]]$ComputerName,
[ValidateSet("All", "Server", "Agent")]
[Parameter(Mandatory = $false)]
[string]$Type
)
$logLead = Get-LogLeadName
$resultObject = @{}
if (!(Test-StringIsNullOrWhitespace -Value $Type)) {
$ComputerName = Get-TeamCityHostnames -Type $Type
}
foreach ($computer in $ComputerName) {
$result = Test-ComputerIsAvailable -ComputerName $computer
Write-Host "$logLead : $computer : $result"
$resultObject += @{$computer = "$result"}
}
Return $resultObject
}