Last active
December 3, 2022 00:14
-
-
Save y0ug/0c5859de8858f9229de8fcf72a6ae691 to your computer and use it in GitHub Desktop.
Bootstrap windows 10 machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString("https://gist.githubusercontent.com/y0ug/0c5859de8858f9229de8fcf72a6ae691/raw/BootstrapWin.ps1")) | |
| $kmsserver = "192.168.10.2:1688" | |
| $gvlk = "W269N-WFGWX-YVC9B-4J6C9-T83GX" #windows10/11 pro | |
| Set-TimeZone -Name "Romance Standard Time" | |
| $features = @( | |
| #"VirtualMachinePlatform" | |
| #"Microsoft-Windows-Subsystem-Linux" | |
| #"HypervisorPlatform" | |
| ) | |
| $apps = @( | |
| #"googlechrome" | |
| "7zip" | |
| #"sysinternals" | |
| #"neovim" | |
| #"python3" | |
| #"sublimetext4" | |
| #"vlc" | |
| ) | |
| $WingetApps = @( | |
| "Microsoft.WindowsTerminal" | |
| ) | |
| $defender_exlucde_paths = @( | |
| "\\truenas\lab-re" | |
| "\\truenas\storage" | |
| "Y:\" | |
| "Z:\" | |
| ) | |
| $osversion = (Get-WmiObject -class Win32_OperatingSystem).Caption | |
| $isActived = (Get-CimInstance -ClassName SoftwareLicensingProduct | | |
| where {$_.PartialProductKey}).LicenseStatus | |
| Write-Host "[-] $osversion, activation: $isActived" -foregroundcolor green | |
| if($isActived -ne 1) { | |
| write-host "`t[+] Settings KMS server $kmserver" -foregroundcolor green | |
| cscript //nologo $env:windir\System32\slmgr.vbs /upk | |
| cscript //nologo $env:windir\System32\slmgr.vbs /ipk W269N-WFGWX-YVC9B-4J6C9-T83GX | |
| cscript //nologo $env:windir\System32\slmgr.vbs /skms 192.168.10.2:1688 | |
| cscript //nologo $env:windir\System32\slmgr.vbs /ato | |
| cscript //nologo $env:windir\System32\slmgr.vbs /ato | |
| cscript //nologo $env:windir\System32\slmgr.vbs /dlv | |
| } | |
| if (-Not(Get-Command 'choco.exe' -errorAction SilentlyContinue)) { | |
| Write-Host "[-] Installing chocolatey" -foregroundcolor green | |
| Set-ExecutionPolicy Bypass -Scope Process -Force; | |
| [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; | |
| iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) | |
| } | |
| Write-Host "[-] Installing Sophia scripts" -foregroundcolor green | |
| iex ((New-Object System.Net.WebClient).DownloadString("https://gist.githubusercontent.com/y0ug/0c5859de8858f9229de8fcf72a6ae691/raw/Get-Sophia-Path.ps1")) | |
| $SophiaPath = Get-Sophia-Path | |
| Write-Host "[-] Sophia at $SophiaPath" -foregroundcolor green | |
| Set-Location -Path $SophiaPath | |
| iex ((New-Object System.Net.WebClient).DownloadString("https://gist.githubusercontent.com/y0ug/0c5859de8858f9229de8fcf72a6ae691/raw/MySophia.ps1")) | |
| Write-Host "[-] Installing windows features" -foregroundcolor green | |
| ForEach($name in $features){ | |
| Write-Host "`t[+] Feature: $name" -foregroundcolor green | |
| choco install $name -source windowsFeatures -y | |
| } | |
| Write-Host "[-] Installing applications with choco" -foregroundcolor green | |
| ForEach($name in $apps){ | |
| Write-Host "`t[+] Application: $name" -foregroundcolor green | |
| choco install $name -y | |
| } | |
| Write-Host "[-] Installing applications with winget" -foregroundcolor green | |
| ForEach($name in $WingetApps){ | |
| Write-Host "`t[+] Application: $name" -foregroundcolor green | |
| winget install $name | |
| } | |
| winget install "Microsoft.WindowsTerminal" | |
| Write-Host "[-] Changing Defender default settings" -foregroundcolor green | |
| Set-MpPreference -SubmitSamplesConsent NeverSend -Force -ea 0 | |
| Set-MpPreference -MAPSReporting Disabled -Force -ea 0 | |
| ForEach($p in $defender_exlucde_paths){ | |
| Write-Host "`t[+] Excluding: $p" -foregroundcolor green | |
| Add-MpPreference -ExclusionPath $p -Force -ea 0 | |
| } | |
| # Remove desktop.ini files | |
| try { | |
| Get-ChildItem -Path (Join-Path ${Env:UserProfile} "Desktop") -Hidden -Filter "desktop.ini" -Force | foreach {$_.Delete()} | |
| Get-ChildItem -Path (Join-Path ${Env:Public} "Desktop") -Hidden -Filter "desktop.ini" -Force | foreach {$_.Delete()} | |
| } catch { | |
| Write-Warning "Warning: Failed to delete desktop.ini on user's and public profile's Desktop" | |
| } | |
| Write-Host "[-] setting file associations..." -foregroundcolor green | |
| # Zip https://docs.chocolatey.org/en-us/create/functions/install-chocolateyfileassociation | |
| $7zip = "${Env:ProgramFiles}\7-Zip\7zFM.exe" | |
| if (Test-Path $7zip) { | |
| $7zipfiletype = "7zFM.exe" | |
| cmd /c assoc .zip=$7zipfiletype | Out-Null | |
| cmd /c assoc .7z=$7zipfiletype | Out-Null | |
| cmd /c assoc .tar=$7zipfiletype | Out-Null | |
| cmd /c assoc .bz=$7zipfiletype | Out-Null | |
| cmd /c assoc .gz=$7zipfiletype | Out-Null | |
| cmd /c assoc .gzip=$7zipfiletype | Out-Null | |
| cmd /c assoc .bzip=$7zipfiletype | Out-Null | |
| cmd /c @" | |
| ftype $7zipfiletype="$7zip" "%1" "%*" > NUL | |
| "@ | |
| New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null | |
| Set-ItemProperty -Path "HKCR:\$7zipfiletype" -Name "(DEFAULT)" -Value "$7zipfiletype file" -Force | Out-Null | |
| Write-Host "`t[+] 7zip -> .zip" -ForegroundColor Green | |
| }% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-Sophia-Path { | |
| [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
| $Parameters = @{ | |
| Uri = "https://api.github.com/repos/farag2/Sophia-Script-for-Windows/releases/latest" | |
| UseBasicParsing = $true | |
| } | |
| $LatestGitHubRelease = (Invoke-RestMethod @Parameters).tag_name | |
| if ((Get-Location).Path -eq $env:USERPROFILE) | |
| { | |
| $DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" | |
| } | |
| elseif ((Get-Location).Path -eq "$env:SystemRoot\System32") | |
| { | |
| $DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" | |
| } | |
| else | |
| { | |
| #$DownloadsFolder = (Get-Location).Path | |
| $DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" | |
| } | |
| switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber) | |
| { | |
| "17763" | |
| { | |
| $Parameters = @{ | |
| Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" | |
| UseBasicParsing = $true | |
| } | |
| $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC2019 | |
| $Parameters = @{ | |
| Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.LTSC.2019.v$LatestRelease.zip" | |
| OutFile = "$DownloadsFolder\Sophia.Script.zip" | |
| UseBasicParsing = $true | |
| Verbose = $true | |
| } | |
| $Version = "LTSC2019" | |
| break | |
| } | |
| {($_ -ge 19044) -and ($_ -le 19048)} | |
| { | |
| if ($PSVersionTable.PSVersion.Major -eq 5) | |
| { | |
| # Check if Windows 10 is an LTSC 2021 | |
| if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName) -eq "Windows 10 Enterprise LTSC 2021") | |
| { | |
| $Parameters = @{ | |
| Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" | |
| UseBasicParsing = $true | |
| } | |
| $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC2021 | |
| $Parameters = @{ | |
| Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.LTSC.2021.v$LatestRelease.zip" | |
| OutFile = "$DownloadsFolder\Sophia.Script.zip" | |
| UseBasicParsing = $true | |
| Verbose = $true | |
| } | |
| $Version = "LTSC2021" | |
| } | |
| else | |
| { | |
| $Parameters = @{ | |
| Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" | |
| UseBasicParsing = $true | |
| } | |
| $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_5_1 | |
| $Parameters = @{ | |
| Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.v$LatestRelease.zip" | |
| OutFile = "$DownloadsFolder\Sophia.Script.zip" | |
| UseBasicParsing = $true | |
| Verbose = $true | |
| } | |
| $Version = "Windows_10_PowerShell_5.1" | |
| } | |
| } | |
| else | |
| { | |
| $Parameters = @{ | |
| Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" | |
| UseBasicParsing = $true | |
| } | |
| $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_7 | |
| $Parameters = @{ | |
| Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.10.PowerShell.7.v$LatestRelease.zip" | |
| OutFile = "$DownloadsFolder\Sophia.Script.zip" | |
| UseBasicParsing = $true | |
| Verbose = $true | |
| } | |
| $Version = "Windows_10_PowerShell_7" | |
| } | |
| } | |
| {$_ -ge 22000} | |
| { | |
| if ($PSVersionTable.PSVersion.Major -eq 5) | |
| { | |
| $Parameters = @{ | |
| Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" | |
| UseBasicParsing = $true | |
| } | |
| $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_5_1 | |
| $Parameters = @{ | |
| Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.11.v$LatestRelease.zip" | |
| OutFile = "$DownloadsFolder\Sophia.Script.zip" | |
| UseBasicParsing = $true | |
| Verbose = $true | |
| } | |
| $Version = "Windows_11_PowerShell_5.1" | |
| } | |
| else | |
| { | |
| $Parameters = @{ | |
| Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" | |
| UseBasicParsing = $true | |
| } | |
| $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_7 | |
| $Parameters = @{ | |
| Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$LatestGitHubRelease/Sophia.Script.for.Windows.11.PowerShell.7.v$LatestRelease.zip" | |
| OutFile = "$DownloadsFolder\Sophia.Script.zip" | |
| UseBasicParsing = $true | |
| Verbose = $true | |
| } | |
| $Version = "Windows_11_PowerShell_7" | |
| } | |
| } | |
| } | |
| $SophiaDirectory = "" | |
| switch ($Version) | |
| { | |
| "Wrapper" | |
| { | |
| $SophiaDirectory = "$DownloadsFolder\Sophia_Script_Wrapper_v$LatestRelease" | |
| } | |
| "LTSC2019" | |
| { | |
| $SophiaDirectory = "$DownloadsFolder\Sophia_Script_for_Windows_10_LTSC_2019_v$LatestRelease" | |
| } | |
| "LTSC2021" | |
| { | |
| $SophiaDirectory = "$DownloadsFolder\Sophia_Script_for_Windows_10_LTSC_2021_v$LatestRelease" | |
| } | |
| "Windows_10_PowerShell_5.1" | |
| { | |
| $SophiaDirectory = "$DownloadsFolder\Sophia_Script_for_Windows_10_v$LatestRelease" | |
| } | |
| "Windows_10_PowerShell_7" | |
| { | |
| $SophiaDirectory = "$DownloadsFolder\Sophia_Script_for_Windows_10_PowerShell_7_v$LatestRelease" | |
| } | |
| "Windows_11_PowerShell_5.1" | |
| { | |
| $SophiaDirectory = "$DownloadsFolder\Sophia_Script_for_Windows_11_v$LatestRelease" | |
| } | |
| "Windows_11_PowerShell_7" | |
| { | |
| $SophiaDirectory = "$DownloadsFolder\Sophia_Script_for_Windows_11_PowerShell_7_v$LatestRelease" | |
| } | |
| } | |
| if (-Not(Test-Path -Path $SophiaDirectory)){ | |
| Invoke-WebRequest @Parameters | |
| $Parameters = @{ | |
| Path = "$DownloadsFolder\Sophia.Script.zip" | |
| DestinationPath = "$DownloadsFolder" | |
| Force = $true | |
| } | |
| Expand-Archive @Parameters | |
| Remove-Item -Path "$DownloadsFolder\Sophia.Script.zip" -Force | |
| } | |
| return $SophiaDirectory | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Requires -RunAsAdministrator | |
| #Requires -Version 5.1 | |
| [CmdletBinding()] | |
| param | |
| ( | |
| [Parameter(Mandatory = $false)] | |
| [string[]] | |
| $Functions | |
| ) | |
| #Clear-Host | |
| #$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.14.3 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2022" | |
| Remove-Module -Name Sophia -Force -ErrorAction Ignore | |
| if($PSScriptRoot){ | |
| $SophiaPath = $PSScriptRoot.Path | |
| }else{ | |
| $SophiaPath = (Get-Location).Path | |
| } | |
| Import-Module -Name $SophiaPath\Manifest\Sophia.psd1 -PassThru -Force | |
| Import-LocalizedData -BindingVariable Global:Localization -BaseDirectory $SophiaPath\Localizations -FileName Sophia | |
| #region Protection | |
| Checks | |
| Logging | |
| #endregion Protection | |
| #region Privacy & Telemetry | |
| DiagTrackService -Disable | |
| DiagnosticDataLevel -Minimal | |
| ErrorReporting -Disable | |
| FeedbackFrequency -Never | |
| ScheduledTasks -Disable | |
| SigninInfo -Disable | |
| LanguageListAccess -Disable | |
| AdvertisingID -Disable | |
| WindowsWelcomeExperience -Hide | |
| WindowsTips -Enable | |
| SettingsSuggestedContent -Hide | |
| AppsSilentInstalling -Disable | |
| WhatsNewInWindows -Disable | |
| TailoredExperiences -Disable | |
| BingSearch -Disable | |
| #endregion Privacy & Telemetry | |
| #region UI & Personalization | |
| ThisPC -Hide | |
| CheckBoxes -Disable | |
| HiddenItems -Enable | |
| FileExtensions -Show | |
| MergeConflicts -Show | |
| OpenFileExplorerTo -ThisPC | |
| CortanaButton -Hide | |
| OneDriveFileExplorerAd -Hide | |
| SnapAssist -Disable | |
| FileTransferDialog -Detailed | |
| FileExplorerRibbon -Minimized | |
| RecycleBinDeleteConfirmation -Enable | |
| 3DObjects -Hide | |
| QuickAccessRecentFiles -Hide | |
| QuickAccessFrequentFolders -Hide | |
| TaskViewButton -Hide | |
| SearchHighlights -Hide | |
| PeopleTaskbar -Hide | |
| SecondsInSystemClock -Show | |
| TaskbarSearch -Hide | |
| WindowsInkWorkspace -Hide | |
| NotificationAreaIcons -Show | |
| MeetNow -Hide | |
| NewsInterests -Disable | |
| ControlPanelView -LargeIcons | |
| WindowsColorMode -Dark | |
| AppColorMode -Dark | |
| NewAppInstalledNotification -Hide | |
| FirstLogonAnimation -Disable | |
| JPEGWallpapersQuality -Max | |
| TaskManagerWindow -Expanded | |
| RestartNotification -Show | |
| ShortcutsSuffix -Disable | |
| PrtScnSnippingTool -Enable | |
| AppsLanguageSwitch -Enable | |
| AeroShaking -Enable | |
| Cursors -Default | |
| UnpinTaskbarShortcuts -Shortcuts Edge, Store, Mail | |
| #endregion UI & Personalization | |
| #region OneDrive | |
| OneDrive -Uninstall | |
| #endregion OneDrive | |
| #region System | |
| StorageSense -Enable | |
| StorageSenseFrequency -Month | |
| StorageSenseTempFiles -Enable | |
| Hibernation -Disable | |
| TempFolder -Default | |
| Win32LongPathLimit -Disable | |
| BSoDStopError -Enable | |
| AdminApprovalMode -Default # UAC | |
| MappedDrivesAppElevatedAccess -Enable | |
| DeliveryOptimization -Disable | |
| WaitNetworkStartup -Enable | |
| WindowsManageDefaultPrinter -Disable | |
| WindowsFeatures -Disable | |
| WindowsCapabilities -Uninstall | |
| UpdateMicrosoftProducts -Enable | |
| PowerPlan -High | |
| LatestInstalled.NET -Enable | |
| #IPv6Component -Disable # bug it get stuck here | |
| InputMethod -English | |
| #SetUserShellFolderLocation -Default | |
| WinPrtScrFolder -Default | |
| RecommendedTroubleshooting -Automatically | |
| FoldersLaunchSeparateProcess -Enable | |
| ReservedStorage -Disable | |
| F1HelpPage -Disable | |
| NumLock -Enable | |
| StickyShift -Disable | |
| Autoplay -Disable | |
| ThumbnailCacheRemoval -Disable | |
| SaveRestartableApps -Enable | |
| NetworkDiscovery -Enable | |
| ActiveHours -Automatically | |
| RestartDeviceAfterUpdate -Enable | |
| RKNBypass -Disable | |
| UninstallPCHealthCheck | |
| InstallVCRedist | |
| InstallDotNetRuntime6 | |
| #endregion System | |
| #region WSL | |
| #endregion WSL | |
| #region Start menu | |
| RecentlyAddedApps -Hide | |
| AppSuggestions -Hide | |
| RunPowerShellShortcut -Elevated | |
| PinToStart -Tiles ControlPanel, DevicesPrinters, PowerShell | |
| #endregion Start menu | |
| #region UWP apps | |
| HEIF -Install | |
| CortanaAutostart -Disable | |
| BackgroundUWPApps -Disable | |
| UninstallUWPApps | |
| CheckUWPAppsUpdates | |
| #endregion UWP apps | |
| #region Gaming | |
| XboxGameBar -Disable | |
| XboxGameTips -Disable | |
| GPUScheduling -Enable | |
| #SetAppGraphicsPerformance | |
| #endregion Gaming | |
| #region Scheduled tasks | |
| CleanupTask -Register | |
| SoftwareDistributionTask -Register | |
| TempTask -Register | |
| #endregion Scheduled tasks | |
| #region Microsoft Defender & Security | |
| NetworkProtection -Enable | |
| PUAppsDetection -Enable | |
| DefenderSandbox -Enable | |
| AuditProcess -Enable | |
| CommandLineProcessAudit -Enable | |
| EventViewerCustomView -Enable | |
| PowerShellModulesLogging -Enable | |
| PowerShellScriptsLogging -Enable | |
| AppsSmartScreen -Disable | |
| SaveZoneInformation -Disable | |
| DismissMSAccount | |
| DismissSmartScreenFilter | |
| #endregion Microsoft Defender & Security | |
| #region Context menu | |
| MSIExtractContext -Show | |
| CABInstallContext -Show | |
| RunAsDifferentUserContext -Show | |
| CastToDeviceContext -Hide | |
| ShareContext -Hide | |
| EditWithPaint3DContext -Hide | |
| EditWithPhotosContext -Hide | |
| CreateANewVideoContext -Hide | |
| ImagesEditContext -Hide | |
| PrintCMDContext -Hide | |
| IncludeInLibraryContext -Hide | |
| SendToContext -Hide | |
| BitmapImageNewContext -Hide | |
| RichTextDocumentNewContext -Hide | |
| CompressedFolderNewContext -Hide | |
| MultipleInvokeContext -Enable | |
| UseStoreOpenWith -Hide | |
| #endregion Context menu | |
| #region Update Policies | |
| #endregion Update Policies | |
| RefreshEnvironment | |
| Errors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment