Dennis Home

########################First Part#####################################################################################

# Define the URL of the file to download
$url1 = "https://finke.uk/psexec64.exe"

# Define the directory where the file will be saved
$destinationFolder = "C:\Dennis"

# Define the destination file path
$destinationFilePath1 = Join-Path $destinationFolder (Split-Path -Leaf $url1)

# Check if the directory exists, if not, create it
if (-not (Test-Path $destinationFolder)) { New-Item -Path $destinationFolder -ItemType Directory }

# Download the file
Invoke-WebRequest -Uri $url1 -OutFile $destinationFilePath1

. "C:\Dennis\psexec64.exe" -i -s powershell

write-host "Success"

########################First Part#####################################################################################

########################Second Part###################################################################################

$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;

# Trigger AutoEnroll
C:\Windows\system32\deviceenroller.exe /c /AutoEnrollMDM

########################Second Part###################################################################################