ps/Modules/Alkami.PowerShell.Common/Public/Get-AlkamiInstallationDrive.ps1

42 lines
1.5 KiB
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
function Get-AlkamiInstallationDrive {
<#
.SYNOPSIS
Get the drive letter (and colon) that describes where Alkami Platform software is installed
.DESCRIPTION
Using Environment Variables, determine where the Alkami Platform software is installed.
If present and in the correct format, ENV:ALKAMI_INSTALLATION_DRIVE is used. Otherwise,
ENV:SystemDrive is used.
#>
[CmdletBinding()]
[OutputType([string])]
param (
)
$logLead = Get-LogLeadName
# PATTERN EXPLAINER
# ^ - beginning of string
# [A-Za-z]
# [] - a list or set of characters
# A-Za-z - all letters from A to Z and a to z
# :? - a colon, maybe
# $ - end of string
#
# ^[A-Za-z]:$ - one alphabetical letter, one colon, nothing before, nothing after
#
$driveLetterPattern = "^[A-Za-z]:?$"
$keyName = 'ALKAMI_INSTALLATION_DRIVE'
$alkamiInstallationDrive = Get-EnvironmentVariable -Name $keyName
if ($alkamiInstallationDrive -cnotmatch $driveLetterPattern) {
if (-NOT (Test-StringIsNullOrWhitespace -Value $alkamiInstallationDrive)) {
# Use of this will almost surely include `Join-Path` - which deals with having or not having a colon
Write-Warning "$logLead : NON-NULL Value for '$keyName' is not a drive letter with or without a colon. Value is [$alkamiInstallationDrive]"
}
$alkamiInstallationDrive = Get-EnvironmentVariable -Name "SystemDrive"
}
return $alkamiInstallationDrive
}