Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ================ Windows Updates ================
- # Restrict Windows Update P2P only on the local network
- New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization" -Name "Config" -EA SilentlyContinue
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\WMI\AutoLogger\SQMLogger" -Name "Start" -Type DWord -Value 0 -Force -EA SilentlyContinue
- # Do not show me the Windows welcome experience after updates and occasionally
- New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Type DWord "SubscribedContent-310093Enabled" -Value 0 -Force -EA SilentlyContinue
- # Turn off featured SOFTWARE notifications through Windows Update
- New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Type DWord "EnableFeaturedSoftware" -Value 0 -Force -EA SilentlyContinue
- # Delivery Optimization Settings
- New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Type DWord "DownloadMode" -Value 0 -Force -EA SilentlyContinue
- New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Type DWord "DODownloadMode" -Value 0 -Force -EA SilentlyContinue
- New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Settings" -Type DWord "DownloadMode" -Value 0 -Force -EA SilentlyContinue
- # Turn off automatic download/install of store app updates
- New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion" -Name "WindowsStore" -EA SilentlyContinue
- New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsStore" -Name "WindowsUpdate" -EA SilentlyContinue
- New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" -Type DWord "AutoDownload" -Value 2 -Force -EA SilentlyContinue
- # Prevent using sign-in info to automatically finish setting up after an update
- New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Type DWord "ARSOUserConsent" -Value 0 -Force -EA SilentlyContinue
- # Set automatic updates to download and intsall automatically
- New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows" -Name "WindowsUpdate" -EA SilentlyContinue
- New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "AU" -EA SilentlyContinue
- New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name AUOptions -Value 3 -Force -EA SilentlyContinue
- # Disable Automatic Updates and re-install of pre-installed bloatware
- New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft" -Name "WindowsStore" -EA SilentlyContinue
- New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore" -Name "AutoDownload" -Type DWord -Value 2 -Force -EA SilentlyContinue #disable
- # New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore" -Name "AutoDownload" -Type DWord -Value 4 -Force -EA SilentlyContinue #enable
- New-ItemProperty -Path "HKCU:\Control Panel\International\User Profile" -Name "HttpAcceptLanguageOptOut" -Type DWord -Value 1 -Force
- New-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\Explorer" -Name "DisableNotificationCenter" -Type DWord -Value 1 -Force
- New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\ImmersiveShell" -Name "UseActionCenterExperience" -Type DWord -Value 0 -Force -EA SilentlyContinue
- New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "HideSCAHealth" -Type DWord -Value 0 -Force -EA SilentlyContinue
- New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows NT\CurrentVersion\Software Protection Platform" -Name "NoGenTicket" -Type DWord -Value 1 -Force -EA SilentlyContinue
- New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR" -Name "AppCaptureEnabled" -Type DWord -Value 0 -Force -EA SilentlyContinue
- New-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_Enabled" -Type DWord -Value 0 -Force -EA SilentlyContinue
- # Enable driver offerings through Windows Update.
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Name "PreventDeviceMetadataFromNetwork" -ErrorAction SilentlyContinue
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontPromptForWindowsUpdate" -ErrorAction SilentlyContinue
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontSearchWindowsUpdate" -ErrorAction SilentlyContinue
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DriverUpdateWizardWuSearchEnabled" -ErrorAction SilentlyContinue
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ExcludeWUDriversInQualityUpdate" -ErrorAction SilentlyContinue
- # Disable automatic restart
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "NoAutoRebootWithLoggedOnUsers" -ErrorAction SilentlyContinue
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUPowerManagement" -ErrorAction SilentlyContinue
- # Set automatic updates to not download and intsall automatically.
- New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows" -Name "WindowsUpdate" -ErrorAction SilentlyContinue
- New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "AU" -ErrorAction SilentlyContinue
- New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name AUOptions -Value 3 -ErrorAction SilentlyContinue
- ## Set up prerequisites to install PSWindowsUpdate.
- ### We install the package NuGet as a prerequisite to intsall PSWindowsUpdate.
- Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
- ### We add PSGallery to the trusted installer to our reposistories list.
- Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
- ### We install the module PSWindowsUpdate.
- Install-Module PSWindowsUpdate
- ### We add Microsoft Windows as a valid Windows Update supplier, and auto confirm.
- Add-WUServiceManager -ServiceID "7971f918-a847-4430-9279-4a52d1efe18d" -Confirm:$false
- #Define Title
- $host.UI.RawUI.WindowTitle = "Update Windows"
- #Define Function to set color
- function color ($bc,$fc) {
- $a = (Get-Host).UI.RawUI
- $a.BackgroundColor = $bc
- $a.ForegroundColor = $fc ; cls}
- #Set color
- color "DarkGray" "White"
- #Set size of console shell
- cmd /c MODE con:cols=135 lines=30
- # Ensure that services are started
- Start-Service -Name BITS
- Start-Service -Name wuauserv
- Start-Service -Name cryptSvc
- Start-Service -Name msiserver
- # Run the script to install Windows Updates.
- Write-Host('Searching, Downloading, and Installing Updates...')
- Install-WindowsUpdate -AcceptAll -MicrosoftUpdate
- # Reboot Confirmation Prompt, Yes, No, Cancel
- Add-Type -AssemblyName PresentationCore,PresentationFramework
- $msgBody = "Reboot the computer now?"
- $msgTitle = "Confirm Reboot"
- $msgButton = 'YesNoCancel'
- $msgImage = 'Warning'
- $Result = [System.Windows.MessageBox]::Show($msgBody,$msgTitle,$msgButton,$msgImage)
- Write-Host "The user chose: $Result [" ($result).value__ "]"
- If ($Result -eq '6') {
- shutdown -r -c " " -t 15
- }
- If ($Result -eq '7') {
- shutdown -a
- }
- If ($Result -eq '2') {
- Write-Host 'Cancel Action Chosen'
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement