Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. # Add in the .DEFAULT User Profile
  2. $DefaultProfile = "" | Select-Object SID, UserHive
  3. $DefaultProfile.SID = ".DEFAULT"
  4. $DefaultProfile.Userhive = "C:\Users\Public\NTuser.dat"
  5. $UserProfiles += $DefaultProfile
  6. # Loop through each profile on the machine</p>
  7. Foreach ($UserProfile in $UserProfiles) {
  8. # Load User ntuser.dat if it's not already loaded
  9. If (($ProfileWasLoaded = Test-Path Registry::HKEY_USERS\$($UserProfile.SID)) -eq $false) {
  10. Start-Process -FilePath "CMD.EXE" -ArgumentList "/C REG.EXE LOAD HKU\$($UserProfile.SID) $($UserProfile.UserHive)" -Wait -WindowStyle Hidden
  11. }
  12. # Manipulate the registry
  13. $key = "Registry::HKEY_USERS\$($UserProfile.SID)\Software\SomeArchaicSoftware\Configuration"
  14. New-Item -Path $key -Force | Out-Null
  15. New-ItemProperty -Path $key -Name "LoginURL" -Value "https://mednet.uclahealth.org/" -PropertyType STRING -Force | Out-Null
  16. New-ItemProperty -Path $key -Name "DisplayWelcome" -Value 0x00000001 -PropertyType DWORD -Force | Out-Null
  17.  
  18. $key = "$key\UserInfo"
  19. New-Item -Path $key -Force | Out-Null
  20. New-ItemProperty -Path $key -Name "LoginName" -Value "$($ENV:USERDOMAIN)\$($ENV:USERNAME)" -PropertyType STRING -Force | Out-Null
  21. # Unload NTuser.dat
  22. If ($ProfileWasLoaded -eq $false) {
  23. [gc]::Collect()
  24. Start-Sleep 1
  25. Start-Process -FilePath "CMD.EXE" -ArgumentList "/C REG.EXE UNLOAD HKU\$($UserProfile.SID)" -Wait -WindowStyle Hidden| Out-Null
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement