Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Set variables to indicate value and key to set
- $RegistryPath1 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\MDM"
- $Name1 = 'AutoEnrollMDM'
- $Value1 = '1'
- # Create the key if it does not exist
- If (-NOT (Test-Path $RegistryPath1)) {
- New-Item -Path $RegistryPath1 -Force | Out-Null
- }
- # Now set the value
- New-ItemProperty -Path $RegistryPath1 -Name $Name1 -Value $Value1 -PropertyType DWORD -Force
- # Set variables to indicate value and key to set
- $RegistryPath2 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\MDM"
- $Name2 = 'UseAADCredentialType'
- $Value2 = '1'
- # Create the key if it does not exist
- If (-NOT (Test-Path $RegistryPath2)) {
- New-Item -Path $RegistryPath2 -Force | Out-Null
- }
- # Now set the value
- New-ItemProperty -Path $RegistryPath2 -Name $Name2 -Value $Value2 -PropertyType DWORD -Force
- # Set variables to indicate value and key to set
- $RegistryPath3 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\MDM"
- $Name3 = 'MDMApplicationId'
- # Create the key if it does not exist
- If (-NOT (Test-Path $RegistryPath3)) {
- New-Item -Path $RegistryPath3 -Force | Out-Null
- }
- # Now set the value
- New-ItemProperty -Path $RegistryPath3 -Name $Name3 -PropertyType STRING -Force
- $key = 'SYSTEM\CurrentControlSet\Control\CloudDomainJoin\TenantInfo\*'
- $keyinfo = Get-Item "HKLM:\$key"
- $url = $keyinfo.name
- $url = $url.Split("\")[-1]
- $path = "HKLM:\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\TenantInfo\$url"
- New-ItemProperty -LiteralPath $path -Name 'MdmEnrollmentUrl' -Value 'https://enrollment.manage.microsoft.com/enrollmentserver/discovery.svc' -PropertyType String -Force -ea SilentlyContinue;
- New-ItemProperty -LiteralPath $path -Name 'MdmTermsOfUseUrl' -Value 'https://portal.manage.microsoft.com/TermsofUse.aspx' -PropertyType String -Force -ea SilentlyContinue;
- New-ItemProperty -LiteralPath $path -Name 'MdmComplianceUrl' -Value 'https://portal.manage.microsoft.com/?portalAction=Compliance' -PropertyType String -Force -ea SilentlyContinue;
- C:\Windows\system32\deviceenroller.exe /c /AutoEnrollMDM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement