PowerShell Script to quickly setup a win10 environment

deucedeuce37deucedeuce37 Member Posts: 35
# Open a CMD prompt as an administrator and run "powershell Set-ExecutionPolicy RemoteSigned" before using this script
# Copy this script into a file ending with .ps1 and then execute in powershell as an admin

# Don't append "- Shortcut" to new shortcuts
New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ -Name NamingTemplates -Force
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\NamingTemplates -Name "ShortcutNameTemplate" -PropertyType "String" -Value '%s.lnk'

# Show filename extensions and hidden files in windows explorer
$key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced'
Set-ItemProperty $key Hidden 1
Set-ItemProperty $key HideFileExt 0
Stop-Process -processname explorer

# Set windows page file to 32GB
$SystemInfo=Get-WmiObject -Class Win32_ComputerSystem -EnableAllPrivileges
$SystemInfo.AutomaticManagedPageFile = $false
$PageFile = Get-WmiObject -Class Win32_PageFileSetting -Filter "SettingID='pagefile.sys @ C:'"
Set-WmiInstance -Class Win32_PageFileSetting -Arguments @{name="C:\pagefile.sys"; InitialSize = 32768; MaximumSize = 32768} ` -EnableAllPrivileges |Out-Null

# Disable hibernate, which automatically deletes hiberfil.sys
Start-Process 'powercfg.exe' -Verb runAs -ArgumentList '/h off'

# Disable standby/sleep
powercfg -change -standby-timeout-ac 0

# Set commonly recommended environment variables for Claymore, Genoil, and Nheqminer
setx GPU_FORCE_64BIT_PTR 0
setx GPU_MAX_HEAP_SIZE 100
setx GPU_USE_SYNC_OBJECTS 1
setx GPU_SINGLE_ALLOC_PERCENT 100
setx GPU_MAX_ALLOC_PERCENT 100

# Uncomment to remove ALL windows apps. Calculator, sticky notes, and ability to easily install windows store apps will be lost!
# Get-AppxPackage | Remove-AppxPackage

# Remove specific windows store apps without breaking store, calculator, and sticky notes
Get-AppxPackage *3dbuilder* | Remove-AppxPackage
Get-AppxPackage *windowsalarms* | Remove-AppxPackage
Get-AppxPackage *windowscommunicationsapps* | Remove-AppxPackage
Get-AppxPackage *windowscamera* | Remove-AppxPackage
Get-AppxPackage *officehub* | Remove-AppxPackage
Get-AppxPackage *skypeapp* | Remove-AppxPackage
Get-AppxPackage *getstarted* | Remove-AppxPackage
Get-AppxPackage *zunemusic* | Remove-AppxPackage
Get-AppxPackage *windowsmaps* | Remove-AppxPackage
Get-AppxPackage *solitairecollection* | Remove-AppxPackage
Get-AppxPackage *bingfinance* | Remove-AppxPackage
Get-AppxPackage *zunevideo* | Remove-AppxPackage
Get-AppxPackage *bingnews* | Remove-AppxPackage
Get-AppxPackage *onenote* | Remove-AppxPackage
Get-AppxPackage *people* | Remove-AppxPackage
Get-AppxPackage *windowsphone* | Remove-AppxPackage
Get-AppxPackage *photos* | Remove-AppxPackage
Get-AppxPackage *windowsstore* | Remove-AppxPackage
Get-AppxPackage *bingsports* | Remove-AppxPackage
Get-AppxPackage *soundrecorder* | Remove-AppxPackage
Get-AppxPackage *bingweather* | Remove-AppxPackage
Get-AppxPackage *xboxapp* | Remove-AppxPackage
Get-AppxPackage *FarmVille2CountryEscape* | Remove-AppxPackage
Get-AppxPackage *Microsoft.XboxIdentityProvider* | Remove-AppxPackage
Get-AppxPackage *king.com.CandyCrushSodaSaga* | Remove-AppxPackage
Get-AppxPackage *Microsoft.Advertising.Xaml* | Remove-AppxPackage
Get-AppxPackage *Microsoft.WindowsFeedbackHub* | Remove-AppxPackage
Get-AppxPackage *Microsoft.StorePurchaseApp* | Remove-AppxPackage
Get-AppxPackage *Microsoft.Messaging* | Remove-AppxPackage
Get-AppxPackage *PandoraMediaInc* | Remove-AppxPackage
Get-AppxPackage *Drawboard.DrawboardPDF* | Remove-AppxPackage
Get-AppxPackage *Twitter* | Remove-AppxPackage
Get-AppxPackage *Candy* | Remove-AppxPackage
Get-AppxPackage *FarmVille* | Remove-AppxPackage
Get-AppxPackage *One* | Remove-AppxPackage

# Remove OneDrive
write-host Stopping OneDrive
taskkill /f /im OneDrive.exe
timeout /t 3 /nobreak

write-host Uninstalling OneDrive
& $env:SystemRoot\SysWOW64\OneDriveSetup.exe /uninstall
timeout /t 3 /nobreak

write-host Removeing OneDrive from the Explorer Side Panel
REG DELETE "HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f
REG DELETE "HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f

# Remove home group from windows explorer and stop associated services
Set-Service HomeGroupProvider -StartupType Disabled
Stop-Service HomeGroupProvider

# Mark network connection as private to allow searching for and mounting file shares on LAN
Set-NetConnectionProfile -NetworkCategory Private

# Change computername (use your worker name so you can set worker to %computername% in start.bat of your miner)
$name = Read-Host -Prompt 'Input new computer name (use your worker name)'
Rename-Computer -NewName $name

# Enable remote desktop access
set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 1

# Change time zone to mst
tzutil.exe /s "Mountain Standard Time"

# Disable device driver updates
New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\ -Name WindowsUpdate -Force
New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate -Name "ExcludeWUDriversInQualityUpdate" -PropertyType "DWord" -Value '1'

# Disable windows update reboots
New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate -Name AU -Force
New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU -Name "NoAutoRebootWithLoggedOnUsers" -PropertyType "DWord" -Value '1'

# Disable superfetch
Set-Service SysMain -StartupType Disabled
Stop-Service SysMain

# Uncomment next line if you want to disable windows defender
# Set-MpPreference -DisableRealtimeMonitoring $true

$enter = read-host "Many of the changes made require a reboot! Press enter to close this window."

Comments

Sign In or Register to comment.