42 lines
1.5 KiB
PowerShell
42 lines
1.5 KiB
PowerShell
function Test-ORBEnvironmentalVariables {
|
|
<#
|
|
.SYNOPSIS
|
|
Checks to verify that the expected environmental variables are present
|
|
#>
|
|
|
|
[CmdletBinding()]
|
|
Param()
|
|
|
|
$logLead = (Get-LogLeadName);
|
|
|
|
$expectedVariables = @(
|
|
|
|
@{ "Name" = "POD";
|
|
"Description" = "This variable should be set to the name of the POD/Lane or Team Environment. The value must match other servers in the grouping exactly, including case.";
|
|
"ValidationRegex" = "[^\s]+";
|
|
"ValidationError" = "The value for this variable cannot be an empty string"
|
|
},
|
|
|
|
@{ "Name" = "ServerRole";
|
|
"Description" = "This variable should be set to either Web or App, depending on the function of the server";
|
|
"ValidationRegex" = "^(Web|App)$";
|
|
"ValidationError" = "The value for this variable must be either Web or App";
|
|
}
|
|
)
|
|
|
|
foreach ($envVariable in $expectedVariables) {
|
|
$existingVariable = [Environment]::GetEnvironmentVariable($envVariable.Name, "Machine")
|
|
if ([String]::IsNullOrEmpty($existingVariable)) {
|
|
Write-Warning ("$logLead : The enviornmental variable {0} was not found. {1}" -f $envVariable.Name, $envVariable.Description)
|
|
|
|
if ($null -ne $host) {
|
|
Set-ORBEnvironmentalVariables $envVariable
|
|
}
|
|
}
|
|
else {
|
|
Write-Output ("$logLead : Environmental variable {0} found with value {1}" -f $envVariable.Name, $existingVariable)
|
|
}
|
|
}
|
|
}
|
|
|