Skip to content

Instantly share code, notes, and snippets.

@otsmr
Last active January 24, 2020 21:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save otsmr/02779bbe7ee0001051af7e9c8b7bc21b to your computer and use it in GitHub Desktop.
Function Cyan ($string) { Write-Host $string -ForegroundColor Cyan }
Function Green ($string) { Write-Host $string -ForegroundColor Green }
Function Red ($string) { Write-Host $string -ForegroundColor Red }
$reloadExplorer = 0
$restartPC = 0
Green " "
Green " "
Green " Windows 10 Schnelleinrichtung"
Green " v0.1"
Green " Licence MIT"
Green " "
# ----------------------------------------------
# |
# | README
# |
# | Der Benutzer, für den das Skript ausgeführt werden soll, muss ein Administrator sein.
# |
# | Um .ps1-Dateien auszuführen, muss der folgende Befehl als Administrator ausgeführt werden
# | + Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
# |
# | Dann machen Sie es wieder rückgängig mit
# | + Set-ExecutionPolicy -ExecutionPolicy Undefined
# |
# |
# ----------------------------------------------
$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (!$isAdmin) {
Red " Dieses Skript erfordert Administratorrechte"
Red ""
[string]$getAdmin = Read-Host -Prompt "> Sollen diese angefordert werden? [j/n] (j)"
If ($getAdmin -eq "n") {
exit;
}
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break;
}
Cyan " "
Cyan " Einstellungen fuer $env:COMPUTERNAME"
Cyan " "
[string] $changeName = Read-Host -Prompt "> Computername aendern? [j/n] (n)"
[string] $protectSSDs = Read-Host -Prompt "> SSD-Schonen? [j/n] (n)"
[string] $removeAPPs = Read-Host -Prompt "> Apps deinstallieren? [j/n] (n)"
[string] $setupEXPLORER = Read-Host -Prompt "> Explorer einrichten? [j/n] (n)"
[string] $taskbarCLEAN = Read-Host -Prompt "> Taskleiste und Start einrichten? [j/n] (n)"
[string] $enablePRIVACY = Read-Host -Prompt "> Datenschutz verstaerken? [j/n] (n)"
[string] $installProgramms = Read-Host -Prompt "> Programme installieren? [j/n] (n)"
Cyan " "
Cyan ""
Green " Einstellungen gespeichert"
Cyan ""
[string]$start = Read-Host -Prompt "> Starten? [j/n] (n)"
If ($start -eq "n") {
exit;
}
if ($changeName -eq "j") {
whoami
[string]$computerName = Read-Host -Prompt "> Computername eingeben [n: Abbrechen]"
If ($start -eq "n") {
} else {
Rename-Computer -NewName $computerName
$restartPC = 1
}
}
# ----------------------------------
# SSD Optimierende Einstellungen
# ----------------------------------
if ($protectSSDs -eq "j") {
Green " Energiesparmodus deaktivieren"
powercfg -h off
Green " Prefetcher deaktivieren"
$prefetcherPATH = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters"
Set-ItemProperty -Path "HKLM:$prefetcherPATH" -Name "EnablePrefetcher" -Value 0 -Type DWord
Green " Hoechleistung aktivieren"
Try {
$High = powercfg -l | %{if($_.contains("chstleistung")) {$_.split()[3]}}
$Current = $(powercfg -getactivescheme).split()[3]
if ($Current -ne $High) {powercfg -setactive $High}
} Catch {
Write-Warning -Message "Energiesparplan konnte nicht auf hohe Leistung eingestellt werden"
}
Green " Festplatte ausschalten verhindern"
powercfg -x disk-timeout-ac 0
powercfg -x disk-timeout-dc 0
}
# ----------------------------------
# Taskleiste und Start anpassen
# ----------------------------------
if ($taskbarCLEAN -eq "j") {
Function newEntry {
param(
[string]$taskbarPATH,
[string]$keyName,
[string]$Name,
[string]$Value
)
if (Test-Path "$taskbarPATH\$keyName") {
Set-ItemProperty -Path "$taskbarPATH\$keyName" -Name $Name -Value $Value -Type "DWord" -Force
} else {
New-Item "$taskbarPATH\$keyName"
New-ItemProperty -Path "$taskbarPATH\$keyName" -Name $Name -Value $Value -Type "DWord" -Force
}
}
Green " Gelegentliche Vorschlaege deaktivieren"
$taskbarPATH = "HKLM:SOFTWARE\Policies\Microsoft\Windows\"
newEntry -taskbarPATH $taskbarPATH -keyName "CloudContent" -Name "DisableWindowsConsumerFeatures" -Value 1
Green " Cortana ausblenden"
$taskbarPATH = "HKLM:SOFTWARE\Policies\Microsoft\Windows\"
newEntry -taskbarPATH $taskbarPATH -keyName "Windows Search" -Name "AllowCortana" -Value 0
Green " Suchfeld verkleinern"
$taskbarPATH = "HKCU:Software\Microsoft\Windows\CurrentVersion\"
newEntry -taskbarPATH $taskbarPATH -keyName "Search" -Name "SearchboxTaskbarMode" -Value 1
Green " Immer alle Icons anzeigen"
$taskbarPATH = "HKCU:Software\Microsoft\Windows\CurrentVersion\"
newEntry -taskbarPATH $taskbarPATH -keyName "Explorer" -Name "EnableAutoTray" -Value 0
$reloadExplorer = 1
}
# ----------------------------------
# Apps entfernen
# ----------------------------------
if ($removeAPPs -eq "j") {
Green " Apps entfernen"
# -> Get-AppxPackage | ft Name, PackageFullName -AutoSize
# Rückgängig machen: Get-AppxPackage | foreach {Add-AppxPackage -register „$($_.InstallLocation)\appxmanifest.xml“ -DisableDevelopmentMod}
$names =
"Microsoft.WindowsCamera",
"Microsoft.WindowsAlarms",
"Microsoft.WindowsSoundRecorder",
"Microsoft.WindowsMaps",
"Microsoft.YourPhone",
"Microsoft.People",
"Microsoft.Messaging",
"Microsoft.GetHelp",
"Microsoft.BingWeather",
"Microsoft.MicrosoftOfficeHub",
"Microsoft.MicrosoftSolitaireCollection",
"Microsoft.Microsoft3DViewer",
"Microsoft.MicrosoftStickyNotes",
"Microsoft.Office.OneNote",
"Microsoft.Print3D",
"Microsoft.SkypeApp",
"Microsoft.ZuneMusic",
"Microsoft.XboxApp",
"Microsoft.ZuneMusic",
"XINGAG.XING",
"Microsoft.Todos",
"Microsoft.ZuneMusic",
"microsoft.windowscommunicationsapps"
ForEach ($name in $names) {
$package = Get-AppxPackage -AllUsers -Name $name
Remove-AppxPackage -Package $package[0].PackageFullName -AllUsers
echo "> $name wurde entfernt"
}
}
# ----------------------------------
# Explorer einrichten
# ----------------------------------
if ($setupEXPLORER -eq "j") {
Green " Erweiterungen bei bekannten Dateitypen einblenden"
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name HideFileExt -Value 0
Green " Ordner-Verknuepfungen entfernen"
Green ""
$folders = @()
[string] $explorer = Read-Host -Prompt "> 3D Objekte entfernen? [j/n] (j)"
if ($explorer -eq "j") { $folders += "{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" }
[string] $explorer = Read-Host -Prompt "> Bilder entfernen? [j/n] (n)"
if ($explorer -eq "j") { $folders += "{24ad3ad4-a569-4530-98e1-ab02f9417aa8}" }
[string] $explorer = Read-Host -Prompt "> Dokumente entfernen? [j/n] (n)"
if ($explorer -eq "j") { $folders += "{d3162b92-9365-467a-956b-92703aca08af}" }
[string] $explorer = Read-Host -Prompt "> Musik entfernen? [j/n] (n)"
if ($explorer -eq "j") { $folders += "{3dfdf296-dbec-4fb4-81d1-6a3438bcf4de}" }
[string] $explorer = Read-Host -Prompt "> Videos entfernen? [j/n] (n)"
if ($explorer -eq "j") { $folders += "{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}" }
[string] $explorer = Read-Host -Prompt "> Desktop entfernen? [j/n] (n)"
if ($explorer -eq "j") { $folders += "{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}" }
[string] $explorer = Read-Host -Prompt "> Downloads entfernen? [j/n] (n)"
if ($explorer -eq "j") { $folders += "{d3162b92-9365-467a-956b-92703aca08af}" }
Cyan ""
$base = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace"
ForEach ($folder in $folders) {
Rename-Item -Path "HKLM:$base\$folder" "_$folder"
}
}
# ----------------------------------
# DATENSCHUTZ
# ----------------------------------
if ($enablePRIVACY -eq "j") {
Green " Diatrack deaktiviert"
# -> Get-Service
Stop-Service -Name "DiagTrack" -Force
Set-Service -Name "DiagTrack" -StartupType Disabled
Stop-Service "dmwappushservice" -Force
Set-Service "dmwappushservice" -StartupType Disabled
Green " Windows Defender: Cloudbasierter Schutz deaktiviert"
Set-MpPreference -MAPSReporting 0
Green " Windows Defender: Automatische Übermittelung von Beispielen deaktiviert"
Set-MpPreference -SubmitSamplesConsent 0
Green "Telemetriedaten deaktivieren"
$path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
New-Item -path $path -Force
Set-ItemProperty -path $path -name AllowTelemetry -value "1"
Green " Microsoft Telemetriedomains blockiert"
Add-Content -Path "C:\Windows\System32\drivers\etc\hosts" -Value "
# Microsoft Telemetriedomain
0.0.0.0 geo.settings-win.data.microsoft.com.akadns.net
0.0.0.0 db5-eap.settings-win.data.microsoft.com.akadns.net
0.0.0.0 settings-win.data.microsoft.com
0.0.0.0 db5.settings-win.data.microsoft.com.akadns.net
0.0.0.0 asimov-win.settings.data.microsoft.com.akadns.net
0.0.0.0 db5.vortex.data.microsoft.com.akadns.net
0.0.0.0 v10-win.vortex.data.microsoft.com.akadns.net
0.0.0.0 geo.vortex.data.microsoft.com.akadns.net
0.0.0.0 v10.vortex-win.data.microsoft.com
0.0.0.0 us.vortex-win.data.microsoft.com
0.0.0.0 eu.vortex-win.data.microsoft.com
0.0.0.0 vortex-win-sandbox.data.microsoft.com
0.0.0.0 alpha.telemetry.microsoft.com
0.0.0.0 oca.telemetry.microsoft.com
0.0.0.0 tsfe.trafficshaping.dsp.mp.microsoft.com
0.0.0.0 ceuswatcab01.blob.core.windows.net
0.0.0.0 ceuswatcab02.blob.core.windows.net
0.0.0.0 eaus2watcab01.blob.core.windows.net
0.0.0.0 eaus2watcab02.blob.core.windows.net
0.0.0.0 weus2watcab01.blob.core.windows.net
0.0.0.0 weus2watcab02.blob.core.windows.net
";
Green " Websuche blockiert"
$path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search"
Set-ItemProperty -path $path -name BingSearchEnabled -Value 0 -Force
Set-ItemProperty -path $path -name AllowSearchToUseLocation -Value 0 -Force
Set-ItemProperty -path $path -name CortanaConsent -Value 0 -Force
$reloadExplorer = 1
}
Green
# ----------------------------------
# Standard Programme installieren
# ----------------------------------
if ($installProgramms -eq "j") {
[string]$firefox = Read-Host -Prompt "Firefox installieren und einrichten? [j/n] (n)"
if ($firefox -eq "j") {
$source = "https://download.mozilla.org/?product=firefox-latest&os=win64&lang=de"
$destination = "$env:tmp/firefox.exe"
Green "Firefox wird heruntergeladen"
if (Get-Command 'Invoke-Webrequest'){
Invoke-WebRequest $source -OutFile $destination
}else{
$WebClient = New-Object System.Net.WebClient
$webclient.DownloadFile($source, $destination)
}
Green "Firefox wird installiert"
Start-Process -FilePath $destination -ArgumentList "/S" -Wait
rm -Force $destination
$PATH = "C:\Program Files\Mozilla Firefox\distribution"
if (!(Test-Path $PATH)) {
New-Item -Path $PATH -ItemType Directory
}
New-Item -Path $PATH -Name "policies.json" -Force -Value '
{
"policies": {
"Bookmarks": [
{
"Placement": "toolbar",
"Title": "TSMR",
"URL": "https://tsmr.eu"
}
],
"DisableFeedbackCommands": true,
"DisableFirefoxAccounts": true,
"DisableFirefoxStudies": true,
"DisableMasterPasswordCreation": true,
"DisablePocket": true,
"DisableProfileImport": true,
"DisableTelemetry": true,
"DisplayBookmarksToolbar": true,
"EnableTrackingProtection": {
"Cryptomining": true,
"Fingerprinting": true,
"Value": true
},
"FirefoxHome": {
"Highlights": false,
"Pocket": false,
"Search": true,
"Snippets": false,
"TopSites": false
},
"NewTabPage": true,
"NoDefaultBookmarks": true,
"OfferToSaveLogins": false,
"OfferToSaveLoginsDefault": false,
"PasswordManagerEnabled": false,
"Preferences": {
"browser.tabs.warnOnClose": false,
"browser.urlbar.suggest.bookmark": true,
"browser.urlbar.suggest.history": true,
"browser.urlbar.suggest.openpage": true
},
"PromptForDownloadLocation": true,
"SanitizeOnShutdown": {
"Cache": true,
"Cookies": false,
"Downloads": false,
"FormData": false,
"History": true,
"OfflineApps": false,
"Sessions": false,
"SiteSettings": false
}
}
}'
Green "Firefox wurde installiert und eingerichtet"
}
}
Green
pause
if ($reloadExplorer -eq 1) {
[string]$Reboot = Read-Host -Prompt "Der Explorer muss neu gestartet werden, wollen Sie sofort einen Neustart? [j/n] (n)"
if ($Reboot -eq "j") {
Stop-Process -ProcessName explorer -Force
}
}
if ($restartPC -eq 1) {
[string]$Reboot = Read-Host -Prompt "Einige Einstellungen werden erst nach dem Neustart wirksam, wollen Sie sofort neu starten? [j/n] (n)"
if ($Reboot -eq "j") {
Restart-Computer -Force
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment