Skip to content

Commit 962dc92

Browse files
committed
test
1 parent 50940cd commit 962dc92

File tree

1 file changed

+53
-40
lines changed

1 file changed

+53
-40
lines changed

jumpcloud-ADMU/Powershell/Tests/Migration.Tests.ps1

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -480,66 +480,79 @@ Describe 'Migration Test Scenarios' {
480480
$initUserSid = Test-UsernameOrSID -Username $localUser
481481
Write-Host "SID: $initUserSid"
482482
# Load the registry hive for the user
483-
REG LOAD HKU\$($initUserSid) "C:\Users\$($localUser)\NTUSER.DAT"
483+
REG LOAD "HKU\$($initUserSid)" "C:\Users\$($localUser)\NTUSER.DAT" *>&1
484+
# Get the last modified time of the NTUSER.DAT.BAK file
485+
if ($?) {
486+
Write-ToLog -Message:('Load Profile: ' + "$ProfilePath\NTUSER.DAT.BAK")
487+
} else {
488+
Write-Host $.Exception.Message
489+
Throw "Could not load profile: $ProfilePath\NTUSER.DAT.BAK"
490+
}
491+
484492

485493
$fileType = ".txt"
486494
New-Item -Path "HKEY_USERS:\$($initUserSid)\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$($fileType)\UserChoice" -Force
487-
488-
# Initialize a single user to migrate:
489495
Set-FTA "C:\Program Files\Windows NT\Accessories\wordpad.exe" $fileType
490496

497+
New-Item -Path "HKEY_USERS:\$($initUserSid)\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\$($protocol)\UserChoice" -Force
498+
Set-PTA -Protocol $protocol -ProgId "notepad"
499+
500+
REG UNLOAD HKU\$($initUserSid)
501+
491502

492503
Start-Migration -AutobindJCUser $false -JumpCloudUserName $migrateUser -SelectedUserName "$ENV:COMPUTERNAME\$localUser" -TempPassword "$($Password)" -SetDefaultWindowsUser $true
493504
# Get the SID of the user
494505
$newUserSid = (New-Object System.Security.Principal.NTAccount($migrateUser)).Translate([System.Security.Principal.SecurityIdentifier]).Value
495506
Write-Host "SID: $sid"
496-
$program = Get-ItemProperty "HKEY_USERS:\$newUserSid\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$extension\UserChoice"
507+
$fta = Get-ItemProperty "HKEY_USERS:\$newUserSid\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$extension\UserChoice"
508+
$pta = Get-ItemProperty "HKEY_USERS:\$newUserSid\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\$($protocol)\UserChoice"
497509
Write-Host $program
498510
# Check if programId is wordpad
499-
$program.ProgId | Should -Match "wordpad"
511+
$fta.ProgId | Should -Match "wordpad"
512+
pta.ProgId | Should -Match "notepad"
500513

501514
}
502515
}
503-
Context 'Set-PTA Test'{
504-
BeforeAll{
505-
# Import /Deploy/uwp_jcadmu.ps1 and use the function Set-FTA
506-
. $PSScriptRoot\..\..\..\Deploy\uwp_jcadmu.ps1
507-
}
508-
It 'Set-PTA should be changed after migration'{
509-
# Change the PTA for .txt files to wordpad
510-
$protocol = "http"
516+
# Context 'Set-PTA Test'{
517+
# BeforeAll{
518+
# # Import /Deploy/uwp_jcadmu.ps1 and use the function Set-FTA
519+
# . $PSScriptRoot\..\..\..\Deploy\uwp_jcadmu.ps1
520+
# }
521+
# It 'Set-PTA should be changed after migration'{
522+
# # Change the PTA for .txt files to wordpad
523+
# $protocol = "http"
511524

512-
$Password = "Temp123!"
513-
$localUser = "ADMU_" + -join ((65..90) + (97..122) | Get-Random -Count 5 | ForEach-Object { [char]$_ })
514-
$migrateUser = "ADMU_" + -join ((65..90) + (97..122) | Get-Random -Count 5 | ForEach-Object { [char]$_ })
515-
if ("HKEY_USERS" -notin (Get-psdrive | select-object name).Name) {
516-
Write-ToLog "Mounting HKEY_USERS to check USER UWP keys"
517-
New-PSDrive -Name:("HKEY_USERS") -PSProvider:("Registry") -Root:("HKEY_USERS")
518-
}
519-
# Initialize a single user to migrate:
520-
InitUser -UserName $localUser -Password $Password
521-
$initUserSid = Test-UsernameOrSID -Username $localUser
522-
Write-Host "SID: $initUserSid"
523-
# Load the registry hive for the user
524-
REG LOAD HKU\$($initUserSid)"C:\Users\$($localUser)\NTUSER.DAT"
525-
$initUserSid = (New-Object System.Security.Principal.NTAccount($localUser)).Translate([System.Security.Principal.SecurityIdentifier]).Value
526-
Write-Host "SID: $initUserSid"
525+
# $Password = "Temp123!"
526+
# $localUser = "ADMU_" + -join ((65..90) + (97..122) | Get-Random -Count 5 | ForEach-Object { [char]$_ })
527+
# $migrateUser = "ADMU_" + -join ((65..90) + (97..122) | Get-Random -Count 5 | ForEach-Object { [char]$_ })
528+
# if ("HKEY_USERS" -notin (Get-psdrive | select-object name).Name) {
529+
# Write-ToLog "Mounting HKEY_USERS to check USER UWP keys"
530+
# New-PSDrive -Name:("HKEY_USERS") -PSProvider:("Registry") -Root:("HKEY_USERS")
531+
# }
532+
# # Initialize a single user to migrate:
533+
# InitUser -UserName $localUser -Password $Password
534+
# $initUserSid = Test-UsernameOrSID -Username $localUser
535+
# Write-Host "SID: $initUserSid"
536+
# # Load the registry hive for the user
537+
# REG LOAD HKU\$($initUserSid) "C:\Users\$($localUser)\NTUSER.DAT"
538+
# $initUserSid = (New-Object System.Security.Principal.NTAccount($localUser)).Translate([System.Security.Principal.SecurityIdentifier]).Value
539+
# Write-Host "SID: $initUserSid"
527540

528-
# Create folders inside hive HKU:\$sid\Software\Microsoft\Windows
529-
New-Item -Path "HKEY_USERS:\$($initUserSid)\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\$($protocol)\UserChoice" -Force
541+
# # Create folders inside hive HKU:\$sid\Software\Microsoft\Windows
542+
# New-Item -Path "HKEY_USERS:\$($initUserSid)\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\$($protocol)\UserChoice" -Force
530543

531-
Set-PTA -Protocol $protocol -ProgId "notepad"
544+
# Set-PTA -Protocol $protocol -ProgId "notepad"
532545

533-
Start-Migration -AutobindJCUser $false -JumpCloudUserName $migrateUser -SelectedUserName "$ENV:COMPUTERNAME\$localUser" -TempPassword "$($Password)" -SetDefaultWindowsUser $true
534-
$newUserSid = (New-Object System.Security.Principal.NTAccount($migrateUser)).Translate([System.Security.Principal.SecurityIdentifier]).Value
546+
# Start-Migration -AutobindJCUser $false -JumpCloudUserName $migrateUser -SelectedUserName "$ENV:COMPUTERNAME\$localUser" -TempPassword "$($Password)" -SetDefaultWindowsUser $true
547+
# $newUserSid = (New-Object System.Security.Principal.NTAccount($migrateUser)).Translate([System.Security.Principal.SecurityIdentifier]).Value
535548

536-
Write-Host "SID: $sid"
537-
$program = Get-ItemProperty "HKEY_USERS:\$newUserSid\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\$($protocol)\UserChoice"
538-
Write-Host $program
539-
# Check if programId is notepad
540-
$program.ProgId | Should -Match "notepad"
541-
}
542-
}
549+
# Write-Host "SID: $sid"
550+
# $program = Get-ItemProperty "HKEY_USERS:\$newUserSid\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\$($protocol)\UserChoice"
551+
# Write-Host $program
552+
# # Check if programId is notepad
553+
# $program.ProgId | Should -Match "notepad"
554+
# }
555+
# }
543556
AfterEach {
544557
Write-Host "`nEnd Test: $testName"
545558
Write-Host "---------------------------`n"

0 commit comments

Comments
 (0)