<# .SYNOPSIS Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks Version: v6.1.2 Date: 16.07.2022 Copyright (c) 2014—2022 farag Copyright (c) 2019—2022 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 11 versions Versions: 21H2/22H2 Builds: 22000.739+, 22509+ Editions: Home/Pro/Enterprise .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 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 build version switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber -ge 22000) { $false { Write-Warning -Message $Localization.UnsupportedOSBuild # 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 # Check for UWP apps updates Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod # 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() Start-Process -FilePath "https://t.me/sophia_chat" exit } } # Check whether the OS minor build version is 739 minimum # https://docs.microsoft.com/en-us/windows/release-health/windows11-release-information # https://support.microsoft.com/en-us/topic/june-14-2022-kb5014697-os-build-22000-739-cd3aaa0b-a8da-44a0-a778-dfb6f1d9ea11 switch ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -ge 739) { $false { if ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber -eq 22000) { $Version = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" Write-Warning -Message ($Localization.UpdateWarning -f $Version.CurrentBuild, $Version.UBR) # 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 # Check for UWP apps updates Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod # 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() Start-Process -FilePath "https://t.me/sophia_chat" 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" 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 switch ($CurrentUserName -ne $LoginUserName) { $true { 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 the OS was destroyed by Sycnex's Windows10Debloater script # https://github.com/Sycnex/Windows10Debloater if (Test-Path -Path $env:SystemDrive\Temp\Windows10Debloater) { Write-Warning -Message $Localization.Windows10DebloaterWarning exit } # Check whether libraries exist in the bin folder $Libraries = @( "$PSScriptRoot\..\bin\Start_Layout\start.bin", "$PSScriptRoot\..\bin\PolicyFileEditor\Commands.ps1", "$PSScriptRoot\..\bin\PolicyFileEditor\Common.ps1", "$PSScriptRoot\..\bin\PolicyFileEditor\PolFileEditor.dll", "$PSScriptRoot\..\bin\PolicyFileEditor\PolicyFileEditor.psd1", "$PSScriptRoot\..\bin\PolicyFileEditor\PolicyFileEditor.psm1" ) if (($Libraries | Test-Path) -contains $false) { 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 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_11_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" 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 } # 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 #region Defender Checkings # 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 $Global:Error.Exception[-1] 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 } # Checking services @("Windefend", "SecurityHealthService", "wscsvc") | ForEach-Object -Process { if ($null -eq (Get-Service -Name $_ -ErrorAction Ignore)) { $Localization.DefenderBroken exit } else { if ((Get-Service -Name $_ -ErrorAction Ignore).Status -eq "running") { $Script:DefenderServices = $true } else { $Script:DefenderServices = $false } } } 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 if ((Get-CimInstance -ClassName MSFT_MpComputerStatus -Namespace root/microsoft/windows/defender).ProductStatus -eq 1) { $Script:DefenderProductStatus = $false } else { $Script:DefenderProductStatus = $true } # 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:DefenderProductStatus -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 Checkings # 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 } } } # 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" -ErrorAction Ignore)."{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 11" -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 Disabling the "Connected User Experiences and Telemetry" service (DiagTrack) can cause you not being able to get Xbox achievements anymore .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 # Disabling the "Connected User Experiences and Telemetry" service (DiagTrack) can cause you not being able to get Xbox achievements anymore 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")}) { # Diagnostic data off if (-not (Test-Path -Path HKLM:\Software\Policies\Microsoft\Windows\DataCollection)) { New-Item -Path HKLM:\Software\Policies\Microsoft\Windows\DataCollection -Force } New-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 0 -Force } else { # Send required diagnostic data if (-not (Test-Path -Path HKLM:\Software\Policies\Microsoft\Windows\DataCollection)) { New-Item -Path HKLM:\Software\Policies\Microsoft\Windows\DataCollection -Force } New-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\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 Remove-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -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 "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 = '