From 87001d30a4ebd073af463baf10d2aa72e232ca7f Mon Sep 17 00:00:00 2001 From: jowj Date: Sat, 4 Jan 2020 18:13:36 -0600 Subject: [PATCH] Move setup scripts to scripts folder. --- scripts/mac-client/deploy-MacWorkstation.py | 39 ++ scripts/nix.py | 84 ++++ scripts/win-client/deploy-WinWorkstation.ps1 | 53 +++ scripts/win-client/deploy-WinWorkstation.psm1 | 373 ++++++++++++++++++ 4 files changed, 549 insertions(+) create mode 100644 scripts/mac-client/deploy-MacWorkstation.py create mode 100644 scripts/nix.py create mode 100644 scripts/win-client/deploy-WinWorkstation.ps1 create mode 100644 scripts/win-client/deploy-WinWorkstation.psm1 diff --git a/scripts/mac-client/deploy-MacWorkstation.py b/scripts/mac-client/deploy-MacWorkstation.py new file mode 100644 index 0000000..4feae21 --- /dev/null +++ b/scripts/mac-client/deploy-MacWorkstation.py @@ -0,0 +1,39 @@ +import os +import sys +import argparse +import subprocess +import pdb + +# brew cask install powershell +# Install brew if we don't have it + +installBrew = [ + """ if test ! $(which brew); then + echo "Installing homebrew..." + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + fi """ +] + +subprocess.run(installBrew) +subprocess.run('brew update') +subprocess.run('brew tap caskroom/cask') + +macPrograms = [ + "powershell", + "git", + "vscode", + "emacs64", + "python2", + "python3", + "docker", + "slack", + "discord", + "keybase", + "spotify", + "1password", + "firefox", + "dropbox", + "conemu", + "virtualbox" +] +subprocess.run('brew install ' + macPrograms) \ No newline at end of file diff --git a/scripts/nix.py b/scripts/nix.py new file mode 100644 index 0000000..6977a84 --- /dev/null +++ b/scripts/nix.py @@ -0,0 +1,84 @@ +import os +import sys +import argparse +import subprocess +import pdb + +add_Repos_Args = [ + "sudo", + "add-apt-repository", + "ppa:nextcloud-devs/client" +] + +download_Powershell_Keys = [ + "wget", + "-q", + "https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb" +] + +add_Powershell_Keys = [ + "sudo", + "dpkg", + "-i", + "packages-microsoft-prod.deb" +] + +update_Apt_Repos = [ + "sudo", + "apt", + "update" +] + +add_Apt_Programs = [ + "sudo", + "apt-get", + "install", + "-y", + "powershell", + "emacs", + "python3.7", + "firefox", + "dropbox", + "docker", + "nextcloud-client" +] + +snapProgramsToAdd = [ + "slack", + "discord", +] + +print("adding repos") +subprocess.run(add_Repos_Args,shell=True) + +print("download powershell key") +subprocess.run(download_Powershell_Keys) + +print("add powershell key") +subprocess.run(add_Powershell_Keys) + +print("updating apt") +subprocess.run(update_Apt_Repos) + +print("installing apt packages") +subprocess.run(add_Apt_Programs) + +#print("installing snap packages") +#subprocess.run('sudo snap install ' + snapProgramsToAdd) + +# post processing for firefox userChrome.css +# cp userChrome.css to the profile directory > chrome > userChrome.css +create_Firefox_Chrome_Folder = [ + "mkdir", + "-p", + "~/.mozilla/firefox/*.default/chrome/" +] + +configure_Firefox = [ + "cp" + "~/Documents/projects/agares/applicationConfiguration/firefox/userChrome.css", + "~/.mozilla/firefox/*.default/chrome/userChrome.css" +] + +subprocess.run(create_Firefox_Chrome_Folder) +subprocess.run(configure_Firefox) diff --git a/scripts/win-client/deploy-WinWorkstation.ps1 b/scripts/win-client/deploy-WinWorkstation.ps1 new file mode 100644 index 0000000..d4ad0e1 --- /dev/null +++ b/scripts/win-client/deploy-WinWorkstation.ps1 @@ -0,0 +1,53 @@ +# handle mass install of programs needed for new windows workstations +Import-Module .\deploy-WinWorkstation.psm1 + +$chocoPrograms = @( + "pwsh", + "git", + "vscode", + "emacs64", + "python2", + "python3", + "docker", + "slack", + "discord", + "keybase", + "spotify", + "1password", + "firefox", + "dropbox", + "conemu", + "virtualbox" +) +choco install $chocoPrograms -y + +DisableAdvertisingID +DisableAppSuggestions +DisableBackgroundApps +DisableCortana +DisableDiagTrack +DisableFeedback +DisableLockScreenSpotlight +DisableMapUpdates +DisableOneDrive +DisableSmartScreen +DisableSMB1 +DisableTelemetry +DisableWebSearch +DisableXboxFeatures +EnableRemoteDesktop +HideTaskbarPeopleIcon +InstallHyperV +InstallLinuxSubsystem +SetExplorerThisPC +SetP2PUpdateLocal +SetPhotoViewerAssociation +ShowKnownExtensions +ShowSmallTaskbarIcons +ShowTaskManagerDetails +ShowTrayIcons +UninstallMsftBloat +UninstallOneDrive +UninstallThirdPartyBloat +UninstallWindowsStore +UnpinStartMenuTiles \ No newline at end of file diff --git a/scripts/win-client/deploy-WinWorkstation.psm1 b/scripts/win-client/deploy-WinWorkstation.psm1 new file mode 100644 index 0000000..a000c0f --- /dev/null +++ b/scripts/win-client/deploy-WinWorkstation.psm1 @@ -0,0 +1,373 @@ +# cribbed from https://gist.github.com/alirobe/7f3b34ad89a159e6daa1 + +Function DisableTelemetry { + Write-Host "Disabling Telemetry..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0 + Disable-ScheduledTask -TaskName "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" | Out-Null + Disable-ScheduledTask -TaskName "Microsoft\Windows\Application Experience\ProgramDataUpdater" | Out-Null + Disable-ScheduledTask -TaskName "Microsoft\Windows\Autochk\Proxy" | Out-Null + Disable-ScheduledTask -TaskName "Microsoft\Windows\Customer Experience Improvement Program\Consolidator" | Out-Null + Disable-ScheduledTask -TaskName "Microsoft\Windows\Customer Experience Improvement Program\UsbCeip" | Out-Null + Disable-ScheduledTask -TaskName "Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector" | Out-Null +} + +Function DisableSmartScreen { + Write-Host "Disabling SmartScreen Filter..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "SmartScreenEnabled" -Type String -Value "Off" + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost" -Name "EnableWebContentEvaluation" -Type DWord -Value 0 + $edge = (Get-AppxPackage -AllUsers "Microsoft.MicrosoftEdge").PackageFamilyName + If (!(Test-Path "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter")) { + New-Item -Path "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" -Name "EnabledV9" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" -Name "PreventOverride" -Type DWord -Value 0 +} + +Function DisableWebSearch { + Write-Host "Disabling Bing Search in Start Menu..." + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" -Name "BingSearchEnabled" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "DisableWebSearch" -Type DWord -Value 1 +} + +Function DisableAppSuggestions { + Write-Host "Disabling Application suggestions..." + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "ContentDeliveryAllowed" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "OemPreInstalledAppsEnabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "PreInstalledAppsEnabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "PreInstalledAppsEverEnabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SilentInstalledAppsEnabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338389Enabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SystemPaneSuggestionsEnabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338388Enabled" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableWindowsConsumerFeatures" -Type DWord -Value 1 +} + +Function DisableBackgroundApps { + Write-Host "Disabling Background application access..." + Get-ChildItem -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications" -Exclude "Microsoft.Windows.Cortana*" | ForEach { + Set-ItemProperty -Path $_.PsPath -Name "Disabled" -Type DWord -Value 1 + Set-ItemProperty -Path $_.PsPath -Name "DisabledByUser" -Type DWord -Value 1 + } +} + +Function DisableLockScreenSpotlight { + Write-Host "Disabling Lock screen spotlight..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "RotatingLockScreenEnabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "RotatingLockScreenOverlayEnabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338387Enabled" -Type DWord -Value 0 +} + +Function DisableMapUpdates { + Write-Host "Disabling automatic Maps updates..." + Set-ItemProperty -Path "HKLM:\SYSTEM\Maps" -Name "AutoUpdateEnabled" -Type DWord -Value 0 +} + +Function DisableFeedback { + Write-Host "Disabling Feedback..." + If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules")) { + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" -Name "NumberOfSIUFInPeriod" -Type DWord -Value 0 + Disable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClient" -ErrorAction SilentlyContinue | Out-Null + Disable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClientOnScenarioDownload" -ErrorAction SilentlyContinue | Out-Null +} + +Function DisableAdvertisingID { + Write-Host "Disabling Advertising ID..." + If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo")) { + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo" | Out-Null + } + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo" -Name "Enabled" -Type DWord -Value 0 + If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy")) { + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy" | Out-Null + } + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy" -Name "TailoredExperiencesWithDiagnosticDataEnabled" -Type DWord -Value 0 +} + +Function DisableCortana { + Write-Host "Disabling Cortana..." + If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings")) { + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" -Name "AcceptedPrivacyPolicy" -Type DWord -Value 0 + If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization")) { + New-Item -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitTextCollection" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitInkCollection" -Type DWord -Value 1 + If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore")) { + New-Item -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" -Name "HarvestContacts" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "AllowCortana" -Type DWord -Value 0 +} + +Function EnableCortana { + Write-Host "Enabling Cortana..." + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" -Name "AcceptedPrivacyPolicy" -ErrorAction SilentlyContinue + If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore")) { + New-Item -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitTextCollection" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitInkCollection" -Type DWord -Value 0 + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" -Name "HarvestContacts" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "AllowCortana" -ErrorAction SilentlyContinue +} + +Function SetP2PUpdateLocal { + Write-Host "Restricting Windows Update P2P only to local network..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -Type DWord -Value 1 + If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization")) { + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization" | Out-Null + } + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization" -Name "SystemSettingsDownloadMode" -Type DWord -Value 3 +} + + +Function SetP2PUpdateInternet { + Write-Host "Unrestricting Windows Update P2P to internet..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization" -Name "SystemSettingsDownloadMode" -ErrorAction SilentlyContinue +} + +Function DisableDiagTrack { + Write-Host "Stopping and disabling Diagnostics Tracking Service..." + Stop-Service "DiagTrack" -WarningAction SilentlyContinue + Set-Service "DiagTrack" -StartupType Disabled +} + +Function DisableSMB1 { + Write-Host "Disabling SMB 1.0 protocol..." + Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force +} + +Function EnableRemoteDesktop { + Write-Host "Enabling Remote Desktop w/o Network Level Authentication..." + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "UserAuthentication" -Type DWord -Value 0 +} + +Function ShowTaskManagerDetails { + Write-Host "Showing task manager details..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Force | Out-Null + } + $preferences = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -ErrorAction SilentlyContinue + If (!($preferences)) { + $taskmgr = Start-Process -WindowStyle Hidden -FilePath taskmgr.exe -PassThru + While (!($preferences)) { + Start-Sleep -m 250 + $preferences = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -ErrorAction SilentlyContinue + } + Stop-Process $taskmgr + } + $preferences.Preferences[28] = 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -Type Binary -Value $preferences.Preferences +} + +# Show small icons in taskbar +Function ShowSmallTaskbarIcons { + Write-Host "Showing small icons in taskbar..." + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarSmallIcons" -Type DWord -Value 1 +} + +Function HideTaskbarPeopleIcon { + Write-Host "Hiding People icon..." + If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People")) { + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" | Out-Null + } + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name "PeopleBand" -Type DWord -Value 0 +} + +Function ShowTrayIcons { + Write-Host "Showing all tray icons..." + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "EnableAutoTray" -Type DWord -Value 0 +} + +Function ShowKnownExtensions { + Write-Host "Showing known file extensions..." + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideFileExt" -Type DWord -Value 0 +} + +Function SetExplorerThisPC { + Write-Host "Changing default Explorer view to This PC..." + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "LaunchTo" -Type DWord -Value 1 +} + +Function DisableOneDrive { + Write-Host "Disabling OneDrive..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Name "DisableFileSyncNGSC" -Type DWord -Value 1 +} + +Function UninstallOneDrive { + Write-Host "Uninstalling OneDrive..." + Stop-Process -Name OneDrive -ErrorAction SilentlyContinue + Start-Sleep -s 3 + $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe" + If (!(Test-Path $onedrive)) { + $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe" + } + Start-Process $onedrive "/uninstall" -NoNewWindow -Wait + Start-Sleep -s 3 + Stop-Process -Name explorer -ErrorAction SilentlyContinue + Start-Sleep -s 3 + Remove-Item -Path "$env:USERPROFILE\OneDrive" -Force -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse -ErrorAction SilentlyContinue + If (!(Test-Path "HKCR:")) { + New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null + } + Remove-Item -Path "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" -Recurse -ErrorAction SilentlyContinue +} + +Function UninstallMsftBloat { + Write-Host "Uninstalling default Microsoft applications..." + Get-AppxPackage "Microsoft.3DBuilder" | Remove-AppxPackage + Get-AppxPackage "Microsoft.BingFinance" | Remove-AppxPackage + Get-AppxPackage "Microsoft.BingNews" | Remove-AppxPackage + Get-AppxPackage "Microsoft.BingSports" | Remove-AppxPackage + Get-AppxPackage "Microsoft.BingWeather" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Getstarted" | Remove-AppxPackage + Get-AppxPackage "Microsoft.MicrosoftOfficeHub" | Remove-AppxPackage + Get-AppxPackage "Microsoft.MicrosoftSolitaireCollection" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Office.OneNote" | Remove-AppxPackage + Get-AppxPackage "Microsoft.People" | Remove-AppxPackage + Get-AppxPackage "Microsoft.SkypeApp" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Windows.Photos" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsAlarms" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsCamera" | Remove-AppxPackage + Get-AppxPackage "microsoft.windowscommunicationsapps" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsMaps" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsPhone" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsSoundRecorder" | Remove-AppxPackage + Get-AppxPackage "Microsoft.ZuneMusic" | Remove-AppxPackage + Get-AppxPackage "Microsoft.ZuneVideo" | Remove-AppxPackage + Get-AppxPackage "Microsoft.AppConnector" | Remove-AppxPackage + Get-AppxPackage "Microsoft.ConnectivityStore" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Office.Sway" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Messaging" | Remove-AppxPackage + Get-AppxPackage "Microsoft.CommsPhone" | Remove-AppxPackage + Get-AppxPackage "Microsoft.MicrosoftStickyNotes" | Remove-AppxPackage + Get-AppxPackage "Microsoft.OneConnect" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsFeedbackHub" | Remove-AppxPackage + Get-AppxPackage "Microsoft.MinecraftUWP" | Remove-AppxPackage + Get-AppxPackage "Microsoft.MicrosoftPowerBIForWindows" | Remove-AppxPackage + Get-AppxPackage "Microsoft.NetworkSpeedTest" | Remove-AppxPackage + Get-AppxPackage "Microsoft.MSPaint" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Microsoft3DViewer" | Remove-AppxPackage + Get-AppxPackage "Microsoft.RemoteDesktop" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Print3D" | Remove-AppxPackage +} + +function UninstallThirdPartyBloat { + Write-Host "Uninstalling default third party applications..." + Get-AppxPackage "9E2F88E3.Twitter" | Remove-AppxPackage + Get-AppxPackage "king.com.CandyCrushSodaSaga" | Remove-AppxPackage + Get-AppxPackage "4DF9E0F8.Netflix" | Remove-AppxPackage + Get-AppxPackage "Drawboard.DrawboardPDF" | Remove-AppxPackage + Get-AppxPackage "D52A8D61.FarmVille2CountryEscape" | Remove-AppxPackage + Get-AppxPackage "GAMELOFTSA.Asphalt8Airborne" | Remove-AppxPackage + Get-AppxPackage "flaregamesGmbH.RoyalRevolt2" | Remove-AppxPackage + Get-AppxPackage "AdobeSystemsIncorporated.AdobePhotoshopExpress" | Remove-AppxPackage + Get-AppxPackage "ActiproSoftwareLLC.562882FEEB491" | Remove-AppxPackage + Get-AppxPackage "D5EA27B7.Duolingo-LearnLanguagesforFree" | Remove-AppxPackage + Get-AppxPackage "Facebook.Facebook" | Remove-AppxPackage + Get-AppxPackage "46928bounde.EclipseManager" | Remove-AppxPackage + Get-AppxPackage "A278AB0D.MarchofEmpires" | Remove-AppxPackage + Get-AppxPackage "KeeperSecurityInc.Keeper" | Remove-AppxPackage + Get-AppxPackage "king.com.BubbleWitch3Saga" | Remove-AppxPackage + Get-AppxPackage "89006A2E.AutodeskSketchBook" | Remove-AppxPackage + Get-AppxPackage "CAF9E577.Plex" | Remove-AppxPackage + Get-AppxPackage "A278AB0D.DisneyMagicKingdoms" | Remove-AppxPackage + Get-AppxPackage "828B5831.HiddenCityMysteryofShadows" | Remove-AppxPackage + Get-AppxPackage "WinZipComputing.WinZipUniversal" | Remove-AppxPackage + Get-AppxPackage "SpotifyAB.SpotifyMusic" | Remove-AppxPackage + Get-AppxPackage "PandoraMediaInc.29680B314EFC2" | Remove-AppxPackage + Get-AppxPackage "2414FC7A.Viber" | Remove-AppxPackage + Get-AppxPackage "64885BlueEdge.OneCalendar" | Remove-AppxPackage + Get-AppxPackage "41038Axilesoft.ACGMediaPlayer" | Remove-AppxPackage +} + +Function UninstallWindowsStore { + Write-Host "Uninstalling Windows Store..." + Get-AppxPackage "Microsoft.DesktopAppInstaller" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsStore" | Remove-AppxPackage +} + +Function InstallWindowsStore { + Write-Host "Installing Windows Store..." + Get-AppxPackage -AllUsers "Microsoft.DesktopAppInstaller" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.WindowsStore" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} +} + +Function DisableXboxFeatures { + Write-Host "Disabling Xbox features..." + Get-AppxPackage "Microsoft.XboxApp" | Remove-AppxPackage + Get-AppxPackage "Microsoft.XboxIdentityProvider" | Remove-AppxPackage + Get-AppxPackage "Microsoft.XboxSpeechToTextOverlay" | Remove-AppxPackage + Get-AppxPackage "Microsoft.XboxGameOverlay" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Xbox.TCUI" | Remove-AppxPackage + Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_Enabled" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR" -Name "AllowGameDVR" -Type DWord -Value 0 +} + +Function InstallLinuxSubsystem { + Write-Host "Installing Linux Subsystem..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowDevelopmentWithoutDevLicense" -Type DWord -Value 1 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowAllTrustedApps" -Type DWord -Value 1 + Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +Function InstallHyperV { + Write-Host "Installing Hyper-V..." + If ((Get-WmiObject -Class "Win32_OperatingSystem").Caption -like "*Server*") { + Install-WindowsFeature -Name "Hyper-V" -IncludeManagementTools -WarningAction SilentlyContinue | Out-Null + } Else { + Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-All" -NoRestart -WarningAction SilentlyContinue | Out-Null + } +} + +Function SetPhotoViewerAssociation { + Write-Host "Setting Photo Viewer association for bmp, gif, jpg, png and tif..." + If (!(Test-Path "HKCR:")) { + New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null + } + ForEach ($type in @("Paint.Picture", "giffile", "jpegfile", "pngfile")) { + New-Item -Path $("HKCR:\$type\shell\open") -Force | Out-Null + New-Item -Path $("HKCR:\$type\shell\open\command") | Out-Null + Set-ItemProperty -Path $("HKCR:\$type\shell\open") -Name "MuiVerb" -Type ExpandString -Value "@%ProgramFiles%\Windows Photo Viewer\photoviewer.dll,-3043" + Set-ItemProperty -Path $("HKCR:\$type\shell\open\command") -Name "(Default)" -Type ExpandString -Value "%SystemRoot%\System32\rundll32.exe `"%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll`", ImageView_Fullscreen %1" + } +} + +# Unpin all Start Menu tiles - Not applicable to Server - Note: This function has no counterpart. You have to pin the tiles back manually. +Function UnpinStartMenuTiles { + Write-Host "Unpinning all Start Menu tiles..." + Get-ChildItem -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount" -Include "*.group" -Recurse | ForEach-Object { + $data = (Get-ItemProperty -Path "$($_.PsPath)\Current" -Name "Data").Data -Join "," + $data = $data.Substring(0, $data.IndexOf(",0,202,30") + 9) + ",0,202,80,0,0" + Set-ItemProperty -Path "$($_.PsPath)\Current" -Name "Data" -Type Binary -Value $data.Split(",") + } +} \ No newline at end of file