<# .SYNOPSIS Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks Version: v5.15.0 Date: 30.01.2023 Copyright (c) 2014—2023 farag Copyright (c) 2019—2023 farag & Inestic Thanks to all https://forum.ru-board.com members involved .NOTES Supported Windows 10 version Version: 21H2 Build: 19044.2364+ Edition: Enterprise LTSC 2021 Architecture: x64 .LINK GitHub https://github.com/farag2/Sophia-Script-for-Windows .LINK Telegram https://t.me/sophianews https://t.me/sophia_chat .LINK Discord https://discord.gg/sSryhaEv79 .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 Checks function Checks { param ( [Parameter(Mandatory = $false)] [switch] $Warning ) Set-StrictMode -Version Latest # Сlear the $Error variable $Global:Error.Clear() # 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 # Detect the OS bitness if (-not [System.Environment]::Is64BitOperatingSystem) { Write-Warning -Message $Localization.UnsupportedOSBitness Start-Process -FilePath "https://t.me/sophia_chat" exit } # Detect the OS build version switch (((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber -eq 19044) -and ((Get-WindowsEdition -Online).Edition -match "EnterpriseS")) { $true { if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -lt 2364) { # Check whether the OS minor build version is 2364 minimum # https://docs.microsoft.com/en-us/windows/release-health/release-information $Version = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR Write-Warning -Message ($Localization.UpdateWarning -f $Version) Start-Process -FilePath "https://t.me/sophia_chat" # Enable receiving 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 } } $false { Write-Warning -Message $Localization.UnsupportedOSBuild Start-Process -FilePath "https://t.me/sophia_chat" exit } } # Check the language mode if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage") { Write-Warning -Message $Localization.UnsupportedLanguageMode Start-Process -FilePath "https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_language_modes" Start-Process -FilePath "https://t.me/sophia_chat" 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 | Where-Object -FilterScript {($_.ProcessName -eq "explorer") -and ($_.SessionId -eq $CurrentSessionId)}).UserName | Select-Object -First 1 | Split-Path -Leaf if ($CurrentUserName -ne $LoginUserName) { Write-Warning -Message $Localization.LoggedInUserNotAdmin Start-Process -FilePath "https://t.me/sophia_chat" 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) Start-Process -FilePath "https://t.me/sophia_chat" exit } # Check whether the script was run via PowerShell ISE if ($Host.Name -match "ISE") { Write-Warning -Message $Localization.UnsupportedISE Start-Process -FilePath "https://t.me/sophia_chat" exit } # Check whether the OS was infected by the Win 10 Tweaker's trojan # https://win10tweaker.ru 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" Start-Process -FilePath "https://t.me/sophia_chat" exit } # Check whether Windows was destroyed by Windows10Debloater # https://github.com/Sycnex/Windows10Debloater if (Test-Path -Path $env:SystemDrive\Temp\Windows10Debloater) { Write-Warning -Message $Localization.SycnexWarning Start-Process -FilePath "https://t.me/sophia_chat" exit } # Check whether Windows was destroyed by Win10BloatRemover # https://github.com/Fs00/Win10BloatRemover if (Test-Path -Path $env:TEMP\.net\Win10BloatRemover) { Write-Warning -Message $Localization.Fs00Warning Start-Process -FilePath "https://t.me/sophia_chat" exit } # Check whether LGPO.exe exists in the bin folder if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe")) { Write-Warning -Message $Localization.Bin Start-Sleep -Seconds 5 Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" Start-Process -FilePath "https://t.me/sophia_chat" exit } # Check for a pending reboot $PendingActions = @( # CBS pending "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootInProgress", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\PackagesPending", # Windows Update pending "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" ) if (($PendingActions | Test-Path) -contains $true) { Write-Warning -Message $Localization.RebootPending Start-Process -FilePath "https://t.me/sophia_chat" exit } # Check if the current module version is the latest one try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # Check the internet connection $Parameters = @{ Uri = "https://www.google.com" Method = "Head" DisableKeepAlive = $true UseBasicParsing = $true } if (-not (Invoke-WebRequest @Parameters).StatusDescription) { return } try { # 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_LTSC2021 $CurrentRelease = (Get-Module -Name Sophia).Version.ToString() if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease) { Write-Warning -Message $Localization.UnsupportedRelease Start-Sleep -Seconds 5 Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" Start-Process -FilePath "https://t.me/sophia_chat" exit } } catch [System.Net.WebException] { Write-Warning -Message ($Localization.NoResponse -f "https://github.com") Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue } } catch [System.Net.WebException] { Write-Warning -Message $Localization.NoInternetConnection Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue } #region Defender checks # Checking whether WMI is corrupted try { Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root/microsoft/windows/defender -ErrorAction Stop | Out-Null } catch [Microsoft.Management.Infrastructure.CimException] { # Provider Load Failure exception Write-Warning -Message $Global:Error.Exception.Message | Select-Object -First 1 Write-Warning -Message $Localization.WindowsBroken Start-Process -FilePath "https://t.me/sophia_chat" exit } # Checking services try { $Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop } catch [Microsoft.PowerShell.Commands.ServiceCommandException] { $Localization.WindowsBroken Start-Process -FilePath "https://t.me/sophia_chat" exit } $Script:DefenderServices = ($Services | Where-Object -FilterScript {$_.Status -ne "running"} | Measure-Object).Count -lt $Services.Count if ($null -eq (Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntiVirusProduct -ErrorAction Ignore)) { $Localization.WindowsBroken Start-Process -FilePath "https://t.me/sophia_chat" exit } # Check Microsoft Defender state $productState = (Get-CimInstance -Namespace root/SecurityCenter2 -ClassName Antivirusproduct | Where-Object -FilterScript {$_.instanceGuid -eq "{D68DDC3A-831F-4fae-9E44-DA132C1ACF46}"}).productState $DefenderState = ('0x{0:x}' -f $productState).Substring(3, 2) if ($DefenderState -notmatch "00|01") { $Script:DefenderproductState = $true } else { $Script:DefenderproductState = $false } # Specify whether Antispyware protection is enabled if ((Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root/microsoft/windows/defender).AntispywareEnabled) { $Script:DefenderAntispywareEnabled = $true } else { $Script:DefenderAntispywareEnabled = $false } # https://docs.microsoft.com/en-us/graph/api/resources/intune-devices-windowsdefenderproductstatus?view=graph-rest-beta try { if ($Script:DefenderproductState) { if ((Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root/microsoft/windows/defender).ProductStatus -eq 1) { $Script:DefenderProductStatus = $false } else { $Script:DefenderProductStatus = $true } } else { $Script:DefenderProductStatus = $false } } catch [System.Management.Automation.PropertyNotFoundException] { $Localization.UpdateDefender Start-Process -FilePath "https://t.me/sophia_chat" # Enable receiving 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" # Check for updates 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 } # https://docs.microsoft.com/en-us/graph/api/resources/intune-devices-windowsdefenderproductstatus?view=graph-rest-beta if ((Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root/microsoft/windows/defender).AMEngineVersion -eq "0.0.0.0") { $Script:DefenderAMEngineVersion = $false } else { $Script:DefenderAMEngineVersion = $true } # Check whether Microsoft Defender was turned off # Due to "Set-StrictMode -Version Latest" we have to use try/catch & GetValue() try { if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender", "DisableAntiSpyware", $false) -eq 1) { $Script:DisableAntiSpyware = $true } else { $Script:DisableAntiSpyware = $false } } catch {} # Check whether real-time protection prompts for known malware detection # Due to "Set-StrictMode -Version Latest" we have to use try/catch & GetValue() try { if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableRealtimeMonitoring", $false) -eq 1) { $Script:DisableRealtimeMonitoring = $true } else { $Script:DisableRealtimeMonitoring = $false } } catch {} # Check whether behavior monitoring was disabled # Due to "Set-StrictMode -Version Latest" we have to use try/catch & GetValue() try { if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableBehaviorMonitoring", $false) -eq 1) { $Script:DisableBehaviorMonitoring = $true } else { $Script:DisableBehaviorMonitoring = $false } } catch {} if ($Script:DefenderproductState -and $Script:DefenderServices -and $Script:DefenderAntispywareEnabled -and $Script:DefenderAMEngineVersion -and (-not $Script:DisableAntiSpyware) -and (-not $Script:DisableRealtimeMonitoring) -and (-not $Script:DisableBehaviorMonitoring)) { # Defender is enabled $Script:DefenderEnabled = $true switch ((Get-MpPreference).EnableControlledFolderAccess) { "1" { Write-Warning -Message $Localization.ControlledFolderAccessDisabled # Turn off Controlled folder access to let the script proceed $Script:ControlledFolderAccess = $true Set-MpPreference -EnableControlledFolderAccess Disabled # Open "Ransomware protection" page Start-Process -FilePath windowsdefender://RansomwareProtection } "0" { $Script:ControlledFolderAccess = $false } } } #endregion Defender checks # Display a warning message about whether a user has customized the preset file if ($Warning) { # Get the name of a preset (e.g Sophia.ps1) regardless it was named $PresetName = Split-Path -Path ((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File -match ".ps1"}).File -Leaf $Title = "" $Message = $Localization.CustomizationWarning -f $PresetName $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\..\$PresetName Start-Sleep -Seconds 5 Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" exit } "1" { continue } } } # PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore # 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 Checks #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" -ErrorAction Ignore)."{09F7EDC5-294E-4180-AF6A-FB0E6A0E9513}") | Where-Object -FilterScript {$_ -match [regex]::Escape($SystemDriveUniqueID)} $Script:ComputerRestorePoint = $false if ($null -eq $SystemProtection) { $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 ($Script:ComputerRestorePoint) { Disable-ComputerRestore -Drive $env:SystemDrive } } #endregion Protection #region Set GPO <# .SYNOPSIS Create pre-configured text files for LGPO.exe tool .EXAMPLE Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 0 .NOTES https://techcommunity.microsoft.com/t5/microsoft-security-baselines/lgpo-exe-local-group-policy-object-utility-v1-0/ba-p/701045 .NOTES Machine-wide user #> function script:Set-Policy { [CmdletBinding()] param ( [Parameter( Mandatory = $true, Position = 1 )] [string] [ValidateSet("Computer", "User")] $Scope, [Parameter( Mandatory = $true, Position = 2 )] [string] $Path, [Parameter( Mandatory = $true, Position = 3 )] [string] $Name, [Parameter( Mandatory = $true, Position = 4 )] [ValidateSet("DWORD", "SZ", "EXSZ", "CLEAR")] [string] $Type, [Parameter( Mandatory = $false, Position = 5 )] $Value ) if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc")) { return } switch ($Type) { "CLEAR" { $Policy = @" $Scope $($Path) $($Name) $($Type)`n "@ } default { $Policy = @" $Scope $($Path) $($Name) $($Type):$($Value)`n "@ } } if ($Scope -eq "Computer") { $Path = "$env:TEMP\Computer.txt" } else { $Path = "$env:TEMP\User.txt" } Add-Content -Path $Path -Value $Policy -Encoding Default -Force } #endregion Set GPO #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" { # Security level if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection)) { New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Force } if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) { New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 0 -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 if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) { New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force } Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type CLEAR 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 "Proxy", # If the user has consented to participate in the Windows Customer Experience Improvement Program, this job collects and sends usage data to Microsoft "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 "UsbCeip", # The Windows Disk Diagnostic reports general disk and system information to Microsoft for users participating in the Customer Experience Program "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 = '