Skip to content

Instantly share code, notes, and snippets.

@lennybacon
Last active March 9, 2020 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lennybacon/c42d36469bef24842e49d3917a46429f to your computer and use it in GitHub Desktop.
Save lennybacon/c42d36469bef24842e49d3917a46429f to your computer and use it in GitHub Desktop.
Customize Windows after First Start
Write-Host "Disable Telemetry" -ForegroundColor Cyan;
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name AllowTelemetry -PropertyType DWord -Value 0 -force | Out-Null;
Stop-Service DiagTrack | Out-Null;
Set-Service DiagTrack -startupType Disabled | Out-Null;
Stop-Service dmwappushservice | Out-Null;
Set-Service dmwappushservice -startupType Disabled | Out-Null;
Write-Host "Add Developer Exclusions For Windows Defender" -ForegroundColor Cyan;
Add-MpPreference -ExclusionProcess "light.exe" | Out-Null;
Add-MpPreference -ExclusionProcess "candel.exe" | Out-Null;
Add-MpPreference -ExclusionProcess "msbuild.exe" | Out-Null;
Add-MpPreference -ExclusionProcess "VBCSCompiler.exe" | Out-Null;
Add-MpPreference -ExclusionPath "T:\Temp" | Out-Null;
Add-MpPreference -ExclusionPath "C:\Program Files (x86)\Microsoft Visual Studio\" | Out-Null;
Add-MpPreference -ExclusionPath "C:\Users\TfsBuild\.nuget\" | Out-Null;
Add-MpPreference -ExclusionPath "C:\Program Files (x86)\Microsoft SDKs\" | Out-Null;
Write-Host "Remove search bar and customize search" -ForegroundColor Cyan;
New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "CortanaEnabled" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "CanCortanaBeEnabled" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "DeviceHistoryEnabled" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "EnableProactive" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "SearchboxTaskbarMode" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "CortanaConsent" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "CortanaInAmbientMode" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "BingSearchEnabled" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "HistoryViewEnabled" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "AllowSearchToUseLocation" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Speech_OneCore\Preferences" -Name "VoiceActivationEnableAboveLockscreen" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "DisableWebSearch" -PropertyType DWord -Value 1 -force | Out-Null;
New-ItemProperty -Path "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "ConnectedSearchUseWeb" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "CortanaEnabled" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "CanCortanaBeEnabled" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "DeviceHistoryEnabled" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "EnableProactive" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "SearchboxTaskbarMode" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "CortanaConsent" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "CortanaInAmbientMode" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "BingSearchEnabled" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "HistoryViewEnabled" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "AllowSearchToUseLocation" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Speech_OneCore\Preferences" -Name "VoiceActivationEnableAboveLockscreen" -PropertyType DWord -Value 0 -force | Out-Null;
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -force | Out-Null;
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "AllowCortana" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "AllowCortanaAboveLock" -PropertyType DWord -Value 0 -force | Out-Null;
Write-Host "Remove Windows Store Icon, Task View Icon, Desktops Icon, and Mail icon" -ForegroundColor Cyan;
Remove-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -Force -Recurse -ErrorAction SilentlyContinue | Out-Null;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -PropertyType DWord -Value 0 -force | Out-Null;
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\AllUpView" -force | Out-Null;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\AllUpView" -Name Enabled -PropertyType DWord -Value 0 -force | Out-Null;
#Uninstall Microsoft Mail and Calendar'
Get-AppxPackage -AllUsers *windowscommunicationsapps* | Remove-AppxPackage
#Disabling the Provisioning of Microsoft Mail and Calendar'
Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -like "*windowscommunicationsapps*"} | Remove-AppxProvisionedPackage -Online
#Restart Explorer
Stop-Process -processname "explorer" | Out-Null;
Start-Process "explorer" | Out-Null;
Write-Host "Hide Music folder" -ForegroundColor Cyan;
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{a0c69a99-21c8-4671-8703-7934162fcf1d}\PropertyBag" -Name "ThisPCPolicy" -Value "Hide" -Force | Out-Null;
Write-Host "Hide Videos folder" -ForegroundColor Cyan;
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{35286a68-3c57-41a1-bbb1-0eae73d76c95}\PropertyBag" -Name "ThisPCPolicy" -Value "Hide" -Force | Out-Null;
Write-Host "Hide Pictures folder" -ForegroundColor Cyan;
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{0ddd015d-b06c-45d5-8c4c-f59713854639}\PropertyBag" -Name "ThisPCPolicy" -Value "Hide" -Force | Out-Null;
Write-Host "Delete 3d objects folder" -ForegroundColor Cyan;
Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" -ErrorAction SilentlyContinue -Recurse -Force | Out-Null;
Remove-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" -ErrorAction SilentlyContinue -Recurse -Force | Out-Null;
Write-Host "Set Explorer Launch to This PC " -ForegroundColor Cyan;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name LaunchTo -PropertyType DWord -Value 1 -force | Out-Null;
Write-Host "Set Explorer Mru" -ForegroundColor Cyan;
New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name ShowRecent -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name ShowFrequent -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name ShowRecent -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name ShowFrequent -PropertyType DWord -Value 0 -force | Out-Null;
Write-Host "Show hidden files..." -ForegroundColor Cyan;
$key = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced';
Set-ItemProperty $key Hidden 1 | Out-Null;
Set-ItemProperty $key HideFileExt 0 | Out-Null;
Set-ItemProperty $key ShowSuperHidden 0 | Out-Null;
$key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced';
Set-ItemProperty $key Hidden 1 | Out-Null;
Set-ItemProperty $key HideFileExt 0 | Out-Null;
Set-ItemProperty $key ShowSuperHidden 0 | Out-Null;
Stop-Process -processname "explorer" | Out-Null;
Start-Process "explorer" | Out-Null;
Write-Host "Show Extensions Of Known Files" -ForegroundColor Cyan;
$regkey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced";
Set-ItemProperty -path $regkey -name HideFileExt-value 0 | Out-Null;
Write-Host "Configure remote desktop..." -ForegroundColor Cyan;
& netsh advfirewall Firewall set rule group="Remote Desktop" new enable=yes | Out-Null;
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -Value 0 | Out-Null;
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 1 | Out-Null;
Write-Host "Configure power settings..." -ForegroundColor Cyan;
& powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c | Out-Null;
& powercfg.exe -Change -monitor-timeout-ac 0 | Out-Null;
& powercfg.exe -Change -monitor-timeout-dc 0 | Out-Null;
Write-Host "Set dark theme..." -ForegroundColor Cyan;
$key = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize";
if((Test-Path $key) -ne $true){
New-Item -Path $key -force | Out-Null;
}
Set-ItemProperty -Path $key -Name SystemUsesLightTheme -Type DWord -Value 0 | Out-Null;
Set-ItemProperty -Path $key -Name AppsUseLightTheme -Type DWord -Value 0 | Out-Null;
$key = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize";
if((Test-Path $key) -ne $true){
New-Item -Path $key -force | Out-Null;
}
Set-ItemProperty -Path $key -Name SystemUsesLightTheme -Type DWord -Value 0 | Out-Null;
Set-ItemProperty -Path $key -Name AppsUseLightTheme -Type DWord -Value 0 | Out-Null;
Write-Host "Configure MSDTC..." -ForegroundColor Cyan;
& sc.exe config "MSDTC" start=delayed-auto | Out-Null;
Set-DtcNetworkSetting -DtcName Local -AuthenticationLevel Incoming -InboundTransactionsEnabled 1 -OutboundTransactionsEnabled 1 -RemoteClientAccessEnabled 1 -confirm:$false | Out-Null;
Restart-Service MSDTC | Out-Null;
Write-Host "Disable Edge desktop shortcut" -ForegroundColor Cyan;
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "DisableEdgeDesktopShortcutCreation" -Type DWord -Value 1 -Force | Out-Null;
Write-Host "Disable Game Stuff..." -ForegroundColor Cyan;
#Disable Game DVR
Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_Enabled" -Type DWord -Value 0 -Force | Out-Null;
#Disable Game Monitoring Service
if(Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\xbgm"){
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\xbgm" -Name "Start" -Type DWord -Value 4 -Force | Out-Null;
}
#GameDVR local GP - Computer Config\Admin Templates\Windows Components\Windows Game Recording and Broadcasting
if(Test-Path -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR"){
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR" -Name "AllowGameDVR" -Type DWord -Value 0 -Force | Out-Null;
}
Get-Service XblAuthManager,XblGameSave,XboxNetApiSvc -erroraction silentlycontinue | stop-service -passthru | set-service -startuptype disabled
Write-Host "Disable advertising..." -ForegroundColor Cyan;
#Disabling advertising info and device metadata collection for this machine
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo" -Name "Enabled" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Device Metadata" -Name "PreventDeviceMetadataFromNetwork" -PropertyType DWord -Value 1 -force | Out-Null;
Write-Host "Disable Telemetry..." -ForegroundColor Cyan;
#Set Telemetry to off (switches to 1:basic for W10Pro and lower)
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "AllowTelemetry" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat" -Name "AITEnable" -PropertyType DWord -Value 0 -force | Out-Null;
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat" -Name "DisableInventory" -PropertyType DWord -Value 1 -force | Out-Null;
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy" -Name "TailoredExperiencesWithDiagnosticDataEnabled" -PropertyType DWord -Value 0 -force | Out-Null;
Get-Service Diagtrack,WMPNetworkSvc -erroraction silentlycontinue | stop-service -passthru | set-service -startuptype disabled
Get-Scheduledtask "Microsoft Compatibility Appraiser","ProgramDataUpdater","Consolidator","KernelCeipTask","UsbCeip","Microsoft-Windows-DiskDiagnosticDataCollector","GatherNetworkInfo","QueueReporting" -erroraction silentlycontinue | Disable-scheduledtask
#Do not show feedback notifications
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "DoNotShowFeedbackNotifications" -PropertyType DWord -Value 1 -force | Out-Null;
#Turn off Consumer Experiences - Enterprise only (for Pro, HKCU settings and start menu cleanup achieve same result)
New-ItemProperty -Path "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableWindowsConsumerFeatures" -PropertyType DWord -Value 1 -force | Out-Null;
Write-Host "Remove Apps..." -ForegroundColor Cyan;
$GoodApps = "calculator|sticky|store|windows.photos|soundrecorder|mspaint|screensketch"
$SafeApps = "AAD.brokerplugin|accountscontrol|apprep.chxapp|assignedaccess|asynctext|bioenrollment|capturepicker|cloudexperience|contentdelivery|desktopappinstaller|ecapp|getstarted|immersivecontrolpanel|lockapp|net.native|oobenet|parentalcontrols|PPIProjection|sechealth|secureas|shellexperience|startmenuexperience|vclibs|xaml|XGpuEject|Microsoft.WindowsTerminal"
$SafeApps = "$SafeApps|$GoodApps"
Get-AppxPackage -allusers | where-object {$_.name -notmatch $SafeApps} | Remove-AppxPackage -erroraction silentlycontinue
Get-AppxProvisionedPackage -online | where-object {$_.displayname -notmatch $SafeApps} | Remove-AppxProvisionedPackage -online -erroraction silentlycontinue
Write-Host "Customize Start Menu..." -ForegroundColor Cyan;
#Export-StartLayout -Path ‘C:\users\All Users\Desktop\StartMenuLayout.xml’ -verbose
$startMenu = '<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6">
<start:Group Name="Explore">
<start:Tile Size="1x1" Column="0" Row="0" AppUserModelID="Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge" />
</start:Group>
<start:Group Name="Development">
<start:DesktopApplicationTile Size="1x1" Column="1" Row="0" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Visual Studio Installer.lnk" />
<start:DesktopApplicationTile Size="1x1" Column="2" Row="0" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\VSCodium\VSCodium.lnk" />
<start:DesktopApplicationTile Size="1x1" Column="0" Row="0" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019.lnk" />
</start:Group>
<start:Group Name="Administration">
<start:DesktopApplicationTile Size="1x1" Column="0" Row="0" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Administrative Tools\Event Viewer.lnk" />
<start:DesktopApplicationTile Size="1x1" Column="1" Row="0" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Administrative Tools\services.lnk" />
</start:Group>
</defaultlayout:StartLayout>
</StartLayoutCollection>
</DefaultLayoutOverride>
</LayoutModificationTemplate>' | Out-File "C:\users\All Users\Desktop\StartMenuLayout.xml"
Import-StartLayout -LayoutPath "C:\users\All Users\Desktop\StartMenuLayout.xml" -MountPath "C:\" -verbose;
Write-Host "Unpin Desktop from quick access" -ForegroundColor Cyan;
$QuickAccess = New-Object -ComObject shell.application
($QuickAccess.Namespace("shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}").Items() | where {$_.Name -eq "Desktop"}).InvokeVerb("unpinfromhome")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment