Persist per-machine welcome location

This commit is contained in:
2026-09-17 14:59:35 -06:00
parent 2de1105ecd
commit 351adb0bdc
3 changed files with 46 additions and 6 deletions
+20 -4
View File
@@ -305,6 +305,14 @@ if (-not (Test-Path -LiteralPath $BaseImagePath -PathType Leaf)) {
$userName = [Environment]::UserName
$metadata = $null
$machineLocation = [Environment]::GetEnvironmentVariable('SGU_WELCOME_LOCATION', 'Machine')
$machineOrganizationalUnit = [Environment]::GetEnvironmentVariable(
'SGU_WELCOME_ORGANIZATIONAL_UNIT',
'Machine')
if (-not $machineLocation) { $machineLocation = $env:SGU_WELCOME_LOCATION }
if (-not $machineOrganizationalUnit) {
$machineOrganizationalUnit = $env:SGU_WELCOME_ORGANIZATIONAL_UNIT
}
if (-not $SkipDirectoryLookup) {
try {
$metadata = Get-DirectoryWelcomeMetadata -UserName $userName -MachineName $ComputerName
@@ -320,8 +328,8 @@ if (-not $PSBoundParameters.ContainsKey('DisplayName')) {
if (-not $DisplayName) {
$DisplayName = $userName
}
if (-not $PSBoundParameters.ContainsKey('Location') -and $metadata) {
$Location = $metadata.Location
if (-not $PSBoundParameters.ContainsKey('Location')) {
$Location = if ($machineLocation) { $machineLocation } elseif ($metadata) { $metadata.Location } else { $null }
}
$genderWasProvided = $PSBoundParameters.ContainsKey('Gender')
if (-not $genderWasProvided -and $metadata -and $metadata.Gender -in @('Male', 'Female')) {
@@ -330,8 +338,16 @@ if (-not $genderWasProvided -and $metadata -and $metadata.Gender -in @('Male', '
$Gender = $metadata.Gender
}
$welcomeHeading = Get-WelcomeHeading -Gender $Gender
if (-not $PSBoundParameters.ContainsKey('OrganizationalUnit') -and $metadata) {
$OrganizationalUnit = $metadata.OrganizationalUnit
if (-not $PSBoundParameters.ContainsKey('OrganizationalUnit')) {
$OrganizationalUnit = if ($machineOrganizationalUnit) {
$machineOrganizationalUnit
}
elseif ($metadata) {
$metadata.OrganizationalUnit
}
else {
$null
}
}
$locationText = Get-WelcomeLocationText -Room $Location -OuName $OrganizationalUnit -Gender $Gender