@@ -480,66 +480,79 @@ Describe 'Migration Test Scenarios' {
480
480
$initUserSid = Test-UsernameOrSID - Username $localUser
481
481
Write-Host " SID: $initUserSid "
482
482
# 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
+
484
492
485
493
$fileType = " .txt"
486
494
New-Item - Path " HKEY_USERS:\$ ( $initUserSid ) \Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$ ( $fileType ) \UserChoice" - Force
487
-
488
- # Initialize a single user to migrate:
489
495
Set-FTA " C:\Program Files\Windows NT\Accessories\wordpad.exe" $fileType
490
496
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
+
491
502
492
503
Start-Migration - AutobindJCUser $false - JumpCloudUserName $migrateUser - SelectedUserName " $ENV: COMPUTERNAME \$localUser " - TempPassword " $ ( $Password ) " - SetDefaultWindowsUser $true
493
504
# Get the SID of the user
494
505
$newUserSid = (New-Object System.Security.Principal.NTAccount($migrateUser )).Translate([System.Security.Principal.SecurityIdentifier ]).Value
495
506
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"
497
509
Write-Host $program
498
510
# Check if programId is wordpad
499
- $program.ProgId | Should -Match " wordpad"
511
+ $fta.ProgId | Should -Match " wordpad"
512
+ pta.ProgId | Should -Match " notepad"
500
513
501
514
}
502
515
}
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"
511
524
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"
527
540
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
530
543
531
- Set-PTA - Protocol $protocol - ProgId " notepad"
544
+ # Set-PTA -Protocol $protocol -ProgId "notepad"
532
545
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
535
548
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
+ # }
543
556
AfterEach {
544
557
Write-Host " `n End Test: $testName "
545
558
Write-Host " ---------------------------`n "
0 commit comments