Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @REM This script is tenant specific!
- @powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$_=((Get-Content \"%~f0\") -join \"`n\");iex $_.Substring($_.IndexOf(\"goto :\"+\"EOF\")+9)"
- @goto :EOF
- #Provisioned App Removal List and afterwards loop through the remaining... This list is specific to a default Windows 11 install.
- $DefaultRemove = @(
- "Microsoft.549981C3F5F10"
- "Microsoft.BingNews"
- "Microsoft.BingWeather"
- "Microsoft.GamingApp"
- "Microsoft.GetHelp"
- "Microsoft.Getstarted"
- "Microsoft.MicrosoftOfficeHub"
- "Microsoft.MicrosoftSolitaireCollection"
- "Microsoft.MicrosoftStickyNotes"
- "Microsoft.People"
- "Microsoft.Todos"
- "Microsoft.WindowsAlarms"
- "microsoft.windowscommunicationsapps"
- "Microsoft.WindowsFeedbackHub"
- "Microsoft.WindowsMaps"
- "Microsoft.Xbox.TCUI"
- "Microsoft.XboxGameOverlay"
- "Microsoft.XboxGamingOverlay"
- "Microsoft.XboxIdentityProvider"
- "Microsoft.XboxSpeechToTextOverlay"
- "Microsoft.YourPhone"
- "Microsoft.ZuneMusic"
- "Microsoft.ZuneVideo"
- )
- Write-Host "Removing Microsoft Provisioned Bloat"
- ForEach ($toremove in $DefaultRemove) {
- Get-ProvisionedAppxPackage -Online -ErrorAction SilentlyContinue | Where-Object DisplayName -EQ $toremove | Remove-ProvisionedAppxPackage -Online -AllUsers | Out-Null
- Write-Host "." -NoNewline -ForegroundColor 'Yellow'
- }
- # Clean up user interface
- # Registry modifications with error handling
- try {
- Write-Host "Modifying default user registry settings"
- REG LOAD HKLM\Default C:\Users\Default\NTUSER.DAT
- $RegistryPath = "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
- @{
- "ShowTaskViewButton" = 0
- "TaskbarDa" = 0
- "TaskbarMn" = 0
- }.GetEnumerator() | ForEach-Object {
- New-ItemProperty -Path $RegistryPath -Name $_.Key -Value $_.Value -PropertyType Dword -Force
- }
- REG UNLOAD HKLM\Default
- }
- catch {
- Write-Host "Error modifying registry: $($_.Exception.Message)"
- }
- Set-Culture en-NZ
- Set-WinSystemLocale -SystemLocale en-NZ
- Set-TimeZone -Name 'New Zealand Standard Time'
- Set-WinHomeLocation -GeoId 0xb7
- Set-WinUserLanguageList en-NZ -Force -Confirm:$false
- # Add PC to Autopilot
- $TryAgain = $true
- If (!(tnc).PingSucceeded) {
- Write-Warning "No network available!"
- Write-Host "Please connect an ethernet cable or connect to Wi-Fi and then press any key when connected"
- start ms-availablenetworks:
- $HOST.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | OUT-NULL
- $HOST.UI.RawUI.Flushinputbuffer()
- $TryAgain = (tnc).PingSucceeded
- }
- If (!($TryAgain)) {
- Write-Warning "Unable to access the network - we're quitting"
- } else {
- Try {
- Install-PackageProvider -Name NuGet -Force -Confirm:$false
- Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
- Install-Script -name Get-WindowsAutopilotInfo -Force -Confirm:$false
- Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned
- $AutopilotParams = @{
- Online = $true
- TenantId = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeee' # TenantId
- AppId = 'aaaaaaa-bbbb-cccc-dddd-eeeeeeee' # AppId
- AppSecret = 'MyReallyStrongAppSecret' # AppSecret
- GroupTag = "Autopilot"
- Assign = $true
- }
- Write-Host "Registering device with Windows Autopilot..."
- $autopilotResult = Get-WindowsAutopilotInfo @AutopilotParams
- if ($autopilotResult) {
- Write-Host "Device successfully registered with Autopilot" -ForegroundColor Green
- Restart-Computer -Force -Confirm:$false
- } else {
- Write-Host "Failed to register device with Autopilot" -ForegroundColor Red
- Write-Host "Please contact IT Support" -ForegroundColor Red
- }
- } Catch {
- Clear
- Write-Host "An error has occurred:" -ForegroundColor Red
- Write-Host "$($_.Exception.Message)"
- Write-Host "Please contact IT Support" -ForegroundColor Red
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement