Advertisement
Guest User

Untitled

a guest
Mar 18th, 2025
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. # Set variables to indicate value and key to set
  2. $RegistryPath1 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\MDM"
  3. $Name1 = 'AutoEnrollMDM'
  4. $Value1 = '1'
  5. # Create the key if it does not exist
  6. If (-NOT (Test-Path $RegistryPath1)) {
  7. New-Item -Path $RegistryPath1 -Force | Out-Null
  8. }
  9. # Now set the value
  10. New-ItemProperty -Path $RegistryPath1 -Name $Name1 -Value $Value1 -PropertyType DWORD -Force
  11.  
  12. # Set variables to indicate value and key to set
  13. $RegistryPath2 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\MDM"
  14. $Name2 = 'UseAADCredentialType'
  15. $Value2 = '1'
  16. # Create the key if it does not exist
  17. If (-NOT (Test-Path $RegistryPath2)) {
  18. New-Item -Path $RegistryPath2 -Force | Out-Null
  19. }
  20. # Now set the value
  21. New-ItemProperty -Path $RegistryPath2 -Name $Name2 -Value $Value2 -PropertyType DWORD -Force
  22.  
  23. # Set variables to indicate value and key to set
  24. $RegistryPath3 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\MDM"
  25. $Name3 = 'MDMApplicationId'
  26. # Create the key if it does not exist
  27. If (-NOT (Test-Path $RegistryPath3)) {
  28. New-Item -Path $RegistryPath3 -Force | Out-Null
  29. }
  30. # Now set the value
  31. New-ItemProperty -Path $RegistryPath3 -Name $Name3 -PropertyType STRING -Force
  32.  
  33. $key = 'SYSTEM\CurrentControlSet\Control\CloudDomainJoin\TenantInfo\*'
  34. $keyinfo = Get-Item "HKLM:\$key"
  35. $url = $keyinfo.name
  36. $url = $url.Split("\")[-1]
  37. $path = "HKLM:\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\TenantInfo\$url"
  38.  
  39. New-ItemProperty -LiteralPath $path -Name 'MdmEnrollmentUrl' -Value 'https://enrollment.manage.microsoft.com/enrollmentserver/discovery.svc' -PropertyType String -Force -ea SilentlyContinue;
  40. New-ItemProperty -LiteralPath $path -Name 'MdmTermsOfUseUrl' -Value 'https://portal.manage.microsoft.com/TermsofUse.aspx' -PropertyType String -Force -ea SilentlyContinue;
  41. New-ItemProperty -LiteralPath $path -Name 'MdmComplianceUrl' -Value 'https://portal.manage.microsoft.com/?portalAction=Compliance' -PropertyType String -Force -ea SilentlyContinue;
  42.  
  43. C:\Windows\system32\deviceenroller.exe /c /AutoEnrollMDM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement