New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
get-itemproperty "HKu:\.Default\Control Panel\Keyboard\" | set-itemproperty -name initialkeyboardindicators -value 2
get-itemproperty "HKLM:\\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\" | Set-ItemProperty -name DontDisplayLastUserName -value 0
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultPassword" -ErrorAction SilentlyContinue; Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "AutoAdminLogon" -Value "0"
Install-Module Microsoft.Graph -Scope CurrentUser
Install-Module ExchangeOnlineManagement -Scope CurrentUser
Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
# Ensure TLS 1.2 is used (sometimes required for PSGallery)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Write-Host "Checking if SPO module is installed..."
if (-not (Get-Module -ListAvailable -Name Microsoft.Online.SharePoint.PowerShell)) {
Write-Host "Installing SharePoint Online Management Shell module..."
Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Force -AllowClobber
} else {
Write-Host "Module already installed."
}
Write-Host "Importing SPO module..."
Import-Module Microsoft.Online.SharePoint.PowerShell -Force
Write-Host "Connecting to SharePoint Online Admin Center..."
# Update with your tenant name:
$adminUrl = "https://[[Insert Tenant Name]].sharepoint.com"
Connect-SPOService -Url $adminUrl
Write-Host "Connected! Applying tenant setting..."
Set-SPOTenant -DisableAddShortCutsToOneDrive $True
Write-Host "Done!"
end