diff --git a/Sophia Script/Module/Sophia.psm1 b/Sophia Script/Module/Sophia.psm1 deleted file mode 100644 index 1bcbe1cb..00000000 --- a/Sophia Script/Module/Sophia.psm1 +++ /dev/null @@ -1,12516 +0,0 @@ -<# - .SYNOPSIS - Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks - - Version: v5.12.4 - Date: 05.10.2021 - - Copyright (c) 2014–2021 farag - Copyright (c) 2019–2021 farag & Inestic - - Thanks to all https://forum.ru-board.com members involved - - .NOTES - Running the script is best done on a fresh install because running it on wrong tweaked system may result in errors occurring - - .NOTES - Supported Windows 10 versions - Versions: 2004/20H2/21H1/21H2 - Builds: 19041/19042/19043/19044 - Editions: Home/Pro/Enterprise - Architecture: x64 - - .NOTES - Set execution policy to be able to run scripts only in the current PowerShell session: - Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force - - .LINK GitHub link - https://github.com/farag2/Sophia-Script-for-Windows - - .LINK Telegram channel & group - https://t.me/sophianews - https://t.me/sophia_chat - - .NOTES - https://forum.ru-board.com/topic.cgi?forum=62&topic=30617#15 - https://habr.com/company/skillfactory/blog/553800/ - https://forums.mydigitallife.net/threads/powershell-windows-10-sophia-script.81675/ - https://www.reddit.com/r/PowerShell/comments/go2n5v/powershell_script_setup_windows_10/ - - .LINK Authors - https://github.com/farag2 - https://github.com/Inestic -#> - -#region Checkings -function Checkings -{ - param - ( - [Parameter(Mandatory = $false)] - [switch] - $Warning - ) - - Set-StrictMode -Version Latest - - # Сlear the $Error variable - $Global:Error.Clear() - - # Detect the OS bitness - switch ([System.Environment]::Is64BitOperatingSystem) - { - $false - { - Write-Warning -Message $Localization.UnsupportedOSBitness - exit - } - } - - # Detect the OS build version - switch (((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber -ge 19041) -and ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber -le 19044)) - { - $false - { - Write-Warning -Message $Localization.UnsupportedOSBuild - exit - } - } - - # Check whether the OS minor build version is 1151 minimum - switch ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -ge 1151) - { - $false - { - $Version = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR - Write-Warning -Message ($Localization.UpdateWarning -f $Version) - - # Receive updates for other Microsoft products when you update Windows - (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") - - Start-Sleep -Seconds 1 - - # Open the "Windows Update" page - Start-Process -FilePath "ms-settings:windowsupdate-action" - - Start-Sleep -Seconds 1 - - # Trigger Windows Update for detecting new updates - (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow() - - exit - } - } - - # Check the language mode - switch ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage") - { - $true - { - Write-Warning -Message $Localization.UnsupportedLanguageMode - - Start-Process -FilePath "https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_language_modes" - - exit - } - } - - # Check whether the logged-in user is an admin - $CurrentUserName = (Get-Process -Id $PID -IncludeUserName).UserName | Split-Path -Leaf - $CurrentSessionId = (Get-Process -Id $PID -IncludeUserName).SessionId - $LoginUserName = (Get-Process -IncludeUserName -ErrorAction SilentlyContinue | Where-Object -FilterScript {($_.ProcessName -eq "explorer") -and ($_.SessionId -eq $CurrentSessionId)}).UserName | Select-Object -First 1 | Split-Path -Leaf - - switch ($CurrentUserName -ne $LoginUserName) - { - $true - { - Write-Warning -Message $Localization.LoggedInUserNotAdmin - exit - } - } - - # Check whether the script was run via PowerShell 5.1 - if ($PSVersionTable.PSVersion.Major -ne 5) - { - Write-Warning -Message ($Localization.UnsupportedPowerShell -f $PSVersionTable.PSVersion.Major, $PSVersionTable.PSVersion.Minor) - exit - } - - # Check whether the script was run via PowerShell ISE - if ($Host.Name -match "ISE") - { - Write-Warning -Message $Localization.UnsupportedISE - exit - } - - # Check whether the OS was infected by Win 10 Tweaker - if (Test-Path -Path "HKCU:\Software\Win 10 Tweaker") - { - Write-Warning -Message $Localization.Win10TweakerWarning - - Start-Process -FilePath "https://youtu.be/na93MS-1EkM" - Start-Process -FilePath "https://pikabu.ru/story/byekdor_v_win_10_tweaker_ili_sovremennyie_metodyi_borbyi_s_piratstvom_8227558" - - exit - } - - # Check if the current module version is the latest one - try - { - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - - # https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json - $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 - $CurrentRelease = (Get-Module -Name Sophia).Version.ToString() - switch ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease) - { - $true - { - Write-Warning -Message $Localization.UnsupportedRelease - - Start-Sleep -Seconds 5 - - Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" - exit - } - } - } - catch [System.Net.WebException] - { - Write-Warning -Message ($Localization.NoResponse -f "https://github.com/farag2/Sophia-Script-for-Windows") - Write-Error -Message ($Localization.NoResponse -f "https://github.com/farag2/Sophia-Script-for-Windows") -ErrorAction SilentlyContinue - } - - # Unblock all files in the script folder by removing the Zone.Identifier alternate data stream with a value of "3" - Get-ChildItem -Path $PSScriptRoot\..\ -File -Recurse -Force | Unblock-File - - # Display a warning message about whether a user has customized the preset file - if ($Warning) - { - $Title = "" - $Message = $Localization.CustomizationWarning - $Yes = $Localization.Yes - $No = $Localization.No - $Options = "&$No", "&$Yes" - $DefaultChoice = 0 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) - { - "0" - { - Invoke-Item -Path $PSScriptRoot\..\Sophia.ps1 - - Start-Sleep -Seconds 5 - - Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" - exit - } - "1" - { - continue - } - } - } - - # Turn off Controlled folder access to let the script proceed - switch ((Get-MpPreference).EnableControlledFolderAccess) - { - "1" - { - Write-Warning -Message $Localization.ControlledFolderAccessDisabled - - $Script:ControlledFolderAccess = $true - Set-MpPreference -EnableControlledFolderAccess Disabled - - # Open "Ransomware protection" page - Start-Process -FilePath windowsdefender://RansomwareProtection - } - "0" - { - $Script:ControlledFolderAccess = $false - } - } - - # Save all opened folders in order to restore them after File Explorer restart - $Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke() -} -#endregion Checkings - -#region Protection -# Enable script logging. The log will be being recorded into the script root folder -# To stop logging just close the console or type "Stop-Transcript" -function Logging -{ - $TrascriptFilename = "Log-$((Get-Date).ToString("dd.MM.yyyy-HH-mm"))" - Start-Transcript -Path $PSScriptRoot\..\$TrascriptFilename.txt -Force -} - -# Create a restore point for the system drive -function CreateRestorePoint -{ - $SystemDriveUniqueID = (Get-Volume | Where-Object -FilterScript {$_.DriveLetter -eq "$($env:SystemDrive[0])"}).UniqueID - $SystemProtection = ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients")."{09F7EDC5-294E-4180-AF6A-FB0E6A0E9513}") | Where-Object -FilterScript {$_ -match [regex]::Escape($SystemDriveUniqueID)} - - $ComputerRestorePoint = $false - - switch ($null -eq $SystemProtection) - { - $true - { - $ComputerRestorePoint = $true - Enable-ComputerRestore -Drive $env:SystemDrive - } - } - - # Never skip creating a restore point - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -Name SystemRestorePointCreationFrequency -PropertyType DWord -Value 0 -Force - - Checkpoint-Computer -Description "Sophia Script for Windows 10" -RestorePointType MODIFY_SETTINGS - - # Revert the System Restore checkpoint creation frequency to 1440 minutes - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -Name SystemRestorePointCreationFrequency -PropertyType DWord -Value 1440 -Force - - # Turn off System Protection for the system drive if it was turned off before without deleting the existing restore points - if ($ComputerRestorePoint) - { - Disable-ComputerRestore -Drive $env:SystemDrive - } -} -#endregion Protection - -#region Privacy & Telemetry -<# - .SYNOPSIS - The Connected User Experiences and Telemetry (DiagTrack) service - - .PARAMETER Disable - Disable the Connected User Experiences and Telemetry (DiagTrack) service, and block connection for the Unified Telemetry Client Outbound Traffic - - .PARAMETER Enable - Enable the Connected User Experiences and Telemetry (DiagTrack) service, and allow connection for the Unified Telemetry Client Outbound Traffic - - .EXAMPLE - DiagTrackService -Disable - - .EXAMPLE - DiagTrackService -Enable - - .NOTES - Current user -#> -function DiagTrackService -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Disable" - )] - [switch] - $Disable, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Enable" - )] - [switch] - $Enable - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Disable" - { - # Connected User Experiences and Telemetry - Get-Service -Name DiagTrack | Stop-Service -Force - Get-Service -Name DiagTrack | Set-Service -StartupType Disabled - - # Block connection for the Unified Telemetry Client Outbound Traffic - Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled False -Action Block - } - "Enable" - { - # Connected User Experiences and Telemetry - Get-Service -Name DiagTrack | Set-Service -StartupType Automatic - Get-Service -Name DiagTrack | Start-Service - - # Allow connection for the Unified Telemetry Client Outbound Traffic - Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled True -Action Allow - } - } -} - -<# - .SYNOPSIS - Diagnostic data - - .PARAMETER Minimal - Set the diagnostic data collection to minimum - - .PARAMETER Default - Set the diagnostic data collection to default - - .EXAMPLE - DiagnosticDataLevel -Minimal - - .EXAMPLE - DiagnosticDataLevel -Default - - .NOTES - Machine-wide -#> -function DiagnosticDataLevel -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Minimal" - )] - [switch] - $Minimal, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Default" - )] - [switch] - $Default - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Minimal" - { - if (Get-WindowsEdition -Online | Where-Object -FilterScript {$_.Edition -like "Enterprise*" -or $_.Edition -eq "Education"}) - { - # Security level - New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 0 -Force - } - else - { - # Required diagnostic data - New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 1 -Force - } - New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 1 -Force - - New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 1 -Force - } - "Default" - { - # Optional diagnostic data - New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force - New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force - - New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force - } - } -} - -<# - .SYNOPSIS - Windows Error Reporting - - .PARAMETER Disable - Turn off Windows Error Reporting - - .PARAMETER Enable - Turn on Windows Error Reporting - - .EXAMPLE - ErrorReporting -Disable - - .EXAMPLE - ErrorReporting -Enable - - .NOTES - Current user -#> -function ErrorReporting -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Disable" - )] - [switch] - $Disable, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Enable" - )] - [switch] - $Enable - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Disable" - { - if ((Get-WindowsEdition -Online).Edition -notmatch "Core") - { - Get-ScheduledTask -TaskName QueueReporting | Disable-ScheduledTask - New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name Disabled -PropertyType DWord -Value 1 -Force - } - - Get-Service -Name WerSvc | Stop-Service -Force - Get-Service -Name WerSvc | Set-Service -StartupType Disabled - } - "Enable" - { - Get-ScheduledTask -TaskName QueueReporting | Enable-ScheduledTask - Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore - - Get-Service -Name WerSvc | Set-Service -StartupType Manual - Get-Service -Name WerSvc | Start-Service - } - } -} - -<# - .SYNOPSIS - The feedback frequency - - .PARAMETER Never - Change the feedback frequency to "Never" - - .PARAMETER Automatically - Change feedback frequency to "Automatically" - - .EXAMPLE - FeedbackFrequency -Never - - .EXAMPLE - FeedbackFrequency -Automatically - - .NOTES - Current user -#> -function FeedbackFrequency -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Never" - )] - [switch] - $Never, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Automatically" - )] - [switch] - $Automatically - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Never" - { - if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules)) - { - New-Item -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Force - } - New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name NumberOfSIUFInPeriod -PropertyType DWord -Value 0 -Force - } - "Automatically" - { - Remove-Item -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Force -ErrorAction Ignore - } - } -} - -<# - .SYNOPSIS - The diagnostics tracking scheduled tasks - - .PARAMETER Disable - Turn off the diagnostics tracking scheduled tasks - - .PARAMETER Enable - Turn on the diagnostics tracking scheduled tasks - - .EXAMPLE - ScheduledTasks -Disable - - .EXAMPLE - ScheduledTasks -Enable - - .NOTES - A pop-up dialog box lets a user select tasks - - .NOTES - Current user -#> -function ScheduledTasks -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Disable" - )] - [switch] - $Disable, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Enable" - )] - [switch] - $Enable - ) - - Add-Type -AssemblyName PresentationCore, PresentationFramework - - #region Variables - # Initialize an array list to store the selected scheduled tasks - $SelectedTasks = New-Object -TypeName System.Collections.ArrayList($null) - - # The following tasks will have their checkboxes checked - [string[]]$CheckedScheduledTasks = @( - # Collects program telemetry information if opted-in to the Microsoft Customer Experience Improvement Program - # Сбор телеметрических данных программы при участии в программе улучшения качества ПО - "ProgramDataUpdater", - - # This task collects and uploads autochk SQM data if opted-in to the Microsoft Customer Experience Improvement Program - # Эта задача собирает и загружает данные SQM при участии в программе улучшения качества программного обеспечения - "Proxy", - - # If the user has consented to participate in the Windows Customer Experience Improvement Program, this job collects and sends usage data to Microsoft - # Если пользователь изъявил желание участвовать в программе по улучшению качества программного обеспечения Windows, эта задача будет собирать и отправлять сведения о работе программного обеспечения в Майкрософт - "Consolidator", - - # The USB CEIP (Customer Experience Improvement Program) task collects Universal Serial Bus related statistics and information about your machine and sends it to the Windows Device Connectivity engineering group at Microsoft - # При выполнении задачи программы улучшения качества ПО шины USB (USB CEIP) осуществляется сбор статистических данных об использовании универсальной последовательной шины USB и с ведений о компьютере, которые направляются инженерной группе Майкрософт по вопросам подключения устройств в Windows - "UsbCeip", - - # The Windows Disk Diagnostic reports general disk and system information to Microsoft for users participating in the Customer Experience Program - # Для пользователей, участвующих в программе контроля качества программного обеспечения, служба диагностики дисков Windows предоставляет общие сведения о дисках и системе в корпорацию Майкрософт - "Microsoft-Windows-DiskDiagnosticDataCollector", - - # This task shows various Map related toasts - # Эта задача показывает различные тосты (всплывающие уведомления) приложения "Карты" - "MapsToastTask", - - # This task checks for updates to maps which you have downloaded for offline use - # Эта задача проверяет наличие обновлений для карт, загруженных для автономного использования - "MapsUpdateTask", - - # Initializes Family Safety monitoring and enforcement - # Инициализация контроля и применения правил семейной безопасности - "FamilySafetyMonitor", - - # Synchronizes the latest settings with the Microsoft family features service - # Синхронизирует последние параметры со службой функций семьи учетных записей Майкрософт - "FamilySafetyRefreshTask", - - # XblGameSave Standby Task - "XblGameSaveTask" - ) - - # Check if device has a camera - $DeviceHasCamera = Get-CimInstance -ClassName Win32_PnPEntity | Where-Object -FilterScript {(($_.PNPClass -eq "Camera") -or ($_.PNPClass -eq "Image")) -and ($_.Service -ne "StillCam")} - if (-not $DeviceHasCamera) - { - # Windows Hello - $CheckedScheduledTasks += "FODCleanupTask" - } - #endregion Variables - - #region XAML Markup - # The section defines the design of the upcoming dialog box - [xml]$XAML = ' - - - - - - - - - - - - - - - - - - -