Persist per-machine welcome location
This commit is contained in:
@@ -16,7 +16,9 @@ function Invoke-WelcomeFixture {
|
||||
$DirectoryGender,
|
||||
[string]$ExplicitGender,
|
||||
[string]$DirectoryLocation = 'Sala de pruebas',
|
||||
[string]$DirectoryOu = 'Laboratorio'
|
||||
[string]$DirectoryOu = 'Laboratorio',
|
||||
[string]$MachineLocation,
|
||||
[string]$MachineOu
|
||||
)
|
||||
|
||||
# Replace only the external directory lookup. Execute the actual script,
|
||||
@@ -43,11 +45,19 @@ function Invoke-WelcomeFixture {
|
||||
}
|
||||
if ($ExplicitGender) { $parameters.Gender = $ExplicitGender }
|
||||
$previousLocalAppData = $env:LOCALAPPDATA
|
||||
$previousMachineLocation = $env:SGU_WELCOME_LOCATION
|
||||
$previousMachineOu = $env:SGU_WELCOME_ORGANIZATIONAL_UNIT
|
||||
try {
|
||||
$env:LOCALAPPDATA = $TestDrive
|
||||
$env:SGU_WELCOME_LOCATION = $MachineLocation
|
||||
$env:SGU_WELCOME_ORGANIZATIONAL_UNIT = $MachineOu
|
||||
& $testScript @parameters
|
||||
}
|
||||
finally { $env:LOCALAPPDATA = $previousLocalAppData }
|
||||
finally {
|
||||
$env:LOCALAPPDATA = $previousLocalAppData
|
||||
$env:SGU_WELCOME_LOCATION = $previousMachineLocation
|
||||
$env:SGU_WELCOME_ORGANIZATIONAL_UNIT = $previousMachineOu
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Welcome wallpaper with AD metadata' {
|
||||
@@ -81,4 +91,13 @@ Describe 'Welcome wallpaper with AD metadata' {
|
||||
-DirectoryOu 'Centro de Experiencia Digital'
|
||||
$result.LocationText | Should Be 'Acceso al Aula Flexible del Centro de Experiencia Digital.'
|
||||
}
|
||||
|
||||
It 'keeps machine location metadata when the GPO command has no location arguments' {
|
||||
$result = Invoke-WelcomeFixture -DirectoryGender $null `
|
||||
-DirectoryLocation 'Sala de pruebas' `
|
||||
-DirectoryOu 'Laboratorio' `
|
||||
-MachineLocation 'Aula Flexible' `
|
||||
-MachineOu 'Centro de Experiencia Digital'
|
||||
$result.LocationText | Should Be 'Acceso al Aula Flexible del Centro de Experiencia Digital.'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user