diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index 9eecd710..6b10703e 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -596,7 +596,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); $Script:DefenderProductState = $true # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender", "DisableAntiSpyware", $null) -eq 1) { $Script:AntiSpywareEnabled = $false @@ -607,7 +607,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableRealtimeMonitoring", $null) -eq 1) { $Script:RealtimeMonitoringEnabled = $false @@ -618,7 +618,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableBehaviorMonitoring", $null) -eq 1) { $Script:BehaviorMonitoringEnabled = $false @@ -3397,7 +3397,7 @@ function TaskbarSearch Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name SearchOnTaskbarMode -Type CLEAR # Checking whether small taskbar buttons enabled - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $TaskbarSmallIcons = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarSmallIcons", $null)) if ($TaskbarSmallIcons -eq 1) { @@ -3472,7 +3472,7 @@ function SearchHighlights "Hide" { # Checking whether "Web search in Windows Search" was disabled. It also disable Search Highlights automatically - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $DisableSearchBoxSuggestions = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableSearchBoxSuggestions", $null)) if ($DisableSearchBoxSuggestions -eq 1) { @@ -3665,7 +3665,7 @@ function NewsInterests return } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $MachineId = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SQMClient", "MachineId", $null) if (-not $MachineId) { @@ -6756,7 +6756,7 @@ function NetworkAdaptersSavePower $InterfaceIndex = (Get-CimInstance -ClassName Win32_NetworkAdapter -Namespace root/CIMV2 | Where-Object -FilterScript {$_.NetConnectionStatus -eq 2}).InterfaceIndex if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and ($_.PhysicalMediaType -eq "Native 802.11") -and ($_.InterfaceIndex -eq $InterfaceIndex)}) { - # Get Currently connected Wi-Fi network SSID + # Get currently connected Wi-Fi network SSID $SSID = (Get-NetConnectionProfile).Name } @@ -9110,7 +9110,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) $Extension ) - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $OrigProgID = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null) if ($OrigProgID) { @@ -9118,7 +9118,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) $Script:RegisteredProgIDs += $OrigProgID } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null) -ne "") { # Save possible ProgIds history with extension @@ -9134,7 +9134,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # If ProgId doesn't exist set the specified ProgId for the extensions - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if (-not [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null)) { if (-not (Test-Path -Path "HKCU:\Software\Classes\$Extension")) @@ -9152,7 +9152,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force # Set the system ProgId to the extension parameters for File Explorer to the possible options for the assignment, and if absent set the specified ProgId - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ($OrigProgID) { if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids")) @@ -9220,7 +9220,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # Setting a block on changing the UserChoice section - # Due to "Set-StrictMode -Version Latest" we have to use OpenSubKey() + # We have to use OpenSubKey() due to "Set-StrictMode -Version Latest" $OpenSubKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\UserChoice", "ReadWriteSubTree", "TakeOwnership") if ($OpenSubKey) { @@ -9253,7 +9253,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) ) # If there is the system extension ProgId, write it to the already configured by default - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null)) { if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds)) @@ -9264,7 +9264,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # Setting 'NoOpenWith' for all registered the extension ProgIDs - # Due to "Set-StrictMode -Version Latest" we have to check everything + # We have to check everything due to "Set-StrictMode -Version Latest" if (Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore) { [psobject]$OpenSubkey = (Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore).Property @@ -9293,18 +9293,18 @@ public static int UnloadHive(RegistryHives hive, string subKey) } } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap", $Extension, $null)) { $picture = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore).$Extension } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PBrush\CLSID", "", $null)) { $PBrush = (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore)."(default)" } - # Due to "Set-StrictMode -Version Latest" we have to check everything + # We have to check everything due to "Set-StrictMode -Version Latest" if (Get-Variable -Name picture -ErrorAction Ignore) { if (($picture -eq "picture") -and $PBrush) @@ -9313,7 +9313,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if (([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap", $Extension, $null)) -eq "picture") { $Script:RegisteredProgIDs += "PBrush" @@ -13827,6 +13827,10 @@ function WindowsScriptHost # Skip if a scheduled task exists if ($_.State -eq "Ready") { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + break } } @@ -15205,7 +15209,7 @@ public static void PostMessage() } } - # Apply policies found in registry to re-build database database due to gpedit.msc relies in its own database + # Apply policies found in registry to re-build database database because gpedit.msc relies in its own database if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt")) { if (Test-Path -Path "$env:TEMP\Computer.txt") @@ -15260,7 +15264,7 @@ public static void PostMessage() $taskschd_Process_ID = (Get-CimInstance -ClassName CIM_Process | Where-Object -FilterScript {$_.Name -eq "mmc.exe"} | Where-Object -FilterScript { $_.CommandLine -match "taskschd.msc" }).Handle - # Due to "Set-StrictMode -Version Latest" we have to check before executing + # We have to check before executing due to "Set-StrictMode -Version Latest" if ($taskschd_Process_ID) { Get-Process -Id $taskschd_Process_ID | Stop-Process -Force diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 index 5d9e05eb..23b587ee 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 @@ -314,6 +314,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.TweakerWarning -f $Tweaker) Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -458,6 +459,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f $File) Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -472,6 +474,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -491,6 +494,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -504,6 +508,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -522,6 +527,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -540,6 +546,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -555,7 +562,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); $Script:DefenderProductState = $true # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender", "DisableAntiSpyware", $null) -eq 1) { $Script:AntiSpywareEnabled = $false @@ -566,7 +573,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableRealtimeMonitoring", $null) -eq 1) { $Script:RealtimeMonitoringEnabled = $false @@ -577,7 +584,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableBehaviorMonitoring", $null) -eq 1) { $Script:BehaviorMonitoringEnabled = $false @@ -2844,7 +2851,7 @@ function TaskbarSearch Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name SearchOnTaskbarMode -Type CLEAR # Checking whether small taskbar buttons enabled - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $TaskbarSmallIcons = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarSmallIcons", $null)) if ($TaskbarSmallIcons -eq 1) { @@ -5341,7 +5348,7 @@ function NetworkAdaptersSavePower $InterfaceIndex = (Get-CimInstance -ClassName Win32_NetworkAdapter -Namespace root/CIMV2 | Where-Object -FilterScript {$_.NetConnectionStatus -eq 2}).InterfaceIndex if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and ($_.PhysicalMediaType -eq "Native 802.11") -and ($_.InterfaceIndex -eq $InterfaceIndex)}) { - # Get Currently connected Wi-Fi network SSID + # Get currently connected Wi-Fi network SSID $SSID = (Get-NetConnectionProfile).Name } @@ -7327,7 +7334,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) $Extension ) - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $OrigProgID = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null) if ($OrigProgID) { @@ -7335,7 +7342,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) $Script:RegisteredProgIDs += $OrigProgID } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null) -ne "") { # Save possible ProgIds history with extension @@ -7351,7 +7358,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # If ProgId doesn't exist set the specified ProgId for the extensions - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if (-not [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null)) { if (-not (Test-Path -Path "HKCU:\Software\Classes\$Extension")) @@ -7369,7 +7376,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force # Set the system ProgId to the extension parameters for File Explorer to the possible options for the assignment, and if absent set the specified ProgId - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ($OrigProgID) { if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids")) @@ -7437,7 +7444,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # Setting a block on changing the UserChoice section - # Due to "Set-StrictMode -Version Latest" we have to use OpenSubKey() + # We have to use OpenSubKey() due to "Set-StrictMode -Version Latest" $OpenSubKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\UserChoice", "ReadWriteSubTree", "TakeOwnership") if ($OpenSubKey) { @@ -7470,7 +7477,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) ) # If there is the system extension ProgId, write it to the already configured by default - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null)) { if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds)) @@ -7481,7 +7488,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # Setting 'NoOpenWith' for all registered the extension ProgIDs - # Due to "Set-StrictMode -Version Latest" we have to check everything + # We have to check everything due to "Set-StrictMode -Version Latest" if (Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore) { [psobject]$OpenSubkey = (Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore).Property @@ -7510,18 +7517,18 @@ public static int UnloadHive(RegistryHives hive, string subKey) } } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap", $Extension, $null)) { $picture = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore).$Extension } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PBrush\CLSID", "", $null)) { $PBrush = (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore)."(default)" } - # Due to "Set-StrictMode -Version Latest" we have to check everything + # We have to check everything due to "Set-StrictMode -Version Latest" if (Get-Variable -Name picture -ErrorAction Ignore) { if (($picture -eq "picture") -and $PBrush) @@ -7530,7 +7537,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if (([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap", $Extension, $null)) -eq "picture") { $Script:RegisteredProgIDs += "PBrush" @@ -10592,6 +10599,10 @@ function WindowsScriptHost # Skip if a scheduled task exists if ($_.State -eq "Ready") { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + break } } @@ -11655,7 +11666,7 @@ public static void PostMessage() } } - # Apply policies found in registry to re-build database database due to gpedit.msc relies in its own database + # Apply policies found in registry to re-build database database because gpedit.msc relies in its own database if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt")) { if (Test-Path -Path "$env:TEMP\Computer.txt") @@ -11700,7 +11711,7 @@ public static void PostMessage() $taskschd_Process_ID = (Get-CimInstance -ClassName CIM_Process | Where-Object -FilterScript {$_.Name -eq "mmc.exe"} | Where-Object -FilterScript { $_.CommandLine -match "taskschd.msc" }).Handle - # Due to "Set-StrictMode -Version Latest" we have to check before executing + # We have to check before executing due to "Set-StrictMode -Version Latest" if ($taskschd_Process_ID) { Get-Process -Id $taskschd_Process_ID | Stop-Process -Force diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 index 016aa592..ebdf1c94 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 @@ -314,6 +314,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.TweakerWarning -f $Tweaker) Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -458,6 +459,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f $File) Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -472,6 +474,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -491,6 +494,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -504,6 +508,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -522,6 +527,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -540,6 +546,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -555,7 +562,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); $Script:DefenderProductState = $true # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender", "DisableAntiSpyware", $null) -eq 1) { $Script:AntiSpywareEnabled = $false @@ -566,7 +573,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableRealtimeMonitoring", $null) -eq 1) { $Script:RealtimeMonitoringEnabled = $false @@ -577,7 +584,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableBehaviorMonitoring", $null) -eq 1) { $Script:BehaviorMonitoringEnabled = $false @@ -3064,7 +3071,7 @@ function TaskbarSearch Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name SearchOnTaskbarMode -Type CLEAR # Checking whether small taskbar buttons enabled - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $TaskbarSmallIcons = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarSmallIcons", $null)) if ($TaskbarSmallIcons -eq 1) { @@ -5739,7 +5746,7 @@ function NetworkAdaptersSavePower $InterfaceIndex = (Get-CimInstance -ClassName Win32_NetworkAdapter -Namespace root/CIMV2 | Where-Object -FilterScript {$_.NetConnectionStatus -eq 2}).InterfaceIndex if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and ($_.PhysicalMediaType -eq "Native 802.11") -and ($_.InterfaceIndex -eq $InterfaceIndex)}) { - # Get Currently connected Wi-Fi network SSID + # Get currently connected Wi-Fi network SSID $SSID = (Get-NetConnectionProfile).Name } @@ -7966,7 +7973,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) $Extension ) - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $OrigProgID = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null) if ($OrigProgID) { @@ -7974,7 +7981,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) $Script:RegisteredProgIDs += $OrigProgID } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null) -ne "") { # Save possible ProgIds history with extension @@ -7990,7 +7997,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # If ProgId doesn't exist set the specified ProgId for the extensions - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if (-not [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null)) { if (-not (Test-Path -Path "HKCU:\Software\Classes\$Extension")) @@ -8008,7 +8015,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force # Set the system ProgId to the extension parameters for File Explorer to the possible options for the assignment, and if absent set the specified ProgId - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ($OrigProgID) { if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids")) @@ -8076,7 +8083,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # Setting a block on changing the UserChoice section - # Due to "Set-StrictMode -Version Latest" we have to use OpenSubKey() + # We have to use OpenSubKey() due to "Set-StrictMode -Version Latest" $OpenSubKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\UserChoice", "ReadWriteSubTree", "TakeOwnership") if ($OpenSubKey) { @@ -8109,7 +8116,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) ) # If there is the system extension ProgId, write it to the already configured by default - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null)) { if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds)) @@ -8120,7 +8127,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # Setting 'NoOpenWith' for all registered the extension ProgIDs - # Due to "Set-StrictMode -Version Latest" we have to check everything + # We have to check everything due to "Set-StrictMode -Version Latest" if (Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore) { [psobject]$OpenSubkey = (Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore).Property @@ -8149,18 +8156,18 @@ public static int UnloadHive(RegistryHives hive, string subKey) } } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap", $Extension, $null)) { $picture = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore).$Extension } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PBrush\CLSID", "", $null)) { $PBrush = (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore)."(default)" } - # Due to "Set-StrictMode -Version Latest" we have to check everything + # We have to check everything due to "Set-StrictMode -Version Latest" if (Get-Variable -Name picture -ErrorAction Ignore) { if (($picture -eq "picture") -and $PBrush) @@ -8169,7 +8176,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if (([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap", $Extension, $null)) -eq "picture") { $Script:RegisteredProgIDs += "PBrush" @@ -11714,6 +11721,10 @@ function WindowsScriptHost # Skip if a scheduled task exists if ($_.State -eq "Ready") { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + break } } @@ -13020,7 +13031,7 @@ public static void PostMessage() } } - # Apply policies found in registry to re-build database database due to gpedit.msc relies in its own database + # Apply policies found in registry to re-build database database because gpedit.msc relies in its own database if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt")) { if (Test-Path -Path "$env:TEMP\Computer.txt") @@ -13065,7 +13076,7 @@ public static void PostMessage() $taskschd_Process_ID = (Get-CimInstance -ClassName CIM_Process | Where-Object -FilterScript {$_.Name -eq "mmc.exe"} | Where-Object -FilterScript { $_.CommandLine -match "taskschd.msc" }).Handle - # Due to "Set-StrictMode -Version Latest" we have to check before executing + # We have to check before executing due to "Set-StrictMode -Version Latest" if ($taskschd_Process_ID) { Get-Process -Id $taskschd_Process_ID | Stop-Process -Force diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 index 9fcd8032..365553de 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 @@ -313,6 +313,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.TweakerWarning -f $Tweaker) Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -448,6 +449,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Windows Feature Experience Pack") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -462,6 +464,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f $([WinAPI.GetStrings]::GetString(22029))) Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -475,6 +478,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Store") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -496,6 +500,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f $File) Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -510,6 +515,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -529,6 +535,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -542,6 +549,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -560,6 +568,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -578,6 +587,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows10" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -599,7 +609,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); $Script:DefenderProductState = $true # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender", "DisableAntiSpyware", $null) -eq 1) { $Script:AntiSpywareEnabled = $false @@ -610,7 +620,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableRealtimeMonitoring", $null) -eq 1) { $Script:RealtimeMonitoringEnabled = $false @@ -621,7 +631,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableBehaviorMonitoring", $null) -eq 1) { $Script:BehaviorMonitoringEnabled = $false @@ -3405,7 +3415,7 @@ function TaskbarSearch Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name SearchOnTaskbarMode -Type CLEAR # Checking whether small taskbar buttons enabled - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $TaskbarSmallIcons = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarSmallIcons", $null)) if ($TaskbarSmallIcons -eq 1) { @@ -3480,7 +3490,7 @@ function SearchHighlights "Hide" { # Checking whether "Web search in Windows Search" was disabled. It also disable Search Highlights automatically - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $DisableSearchBoxSuggestions = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableSearchBoxSuggestions", $null)) if ($DisableSearchBoxSuggestions -eq 1) { @@ -3673,7 +3683,7 @@ function NewsInterests return } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $MachineId = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SQMClient", "MachineId", $null) if (-not $MachineId) { @@ -6766,7 +6776,7 @@ function NetworkAdaptersSavePower $InterfaceIndex = (Get-CimInstance -ClassName Win32_NetworkAdapter -Namespace root/CIMV2 | Where-Object -FilterScript {$_.NetConnectionStatus -eq 2}).InterfaceIndex if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and ($_.PhysicalMediaType -eq "Native 802.11") -and ($_.InterfaceIndex -eq $InterfaceIndex)}) { - # Get Currently connected Wi-Fi network SSID + # Get currently connected Wi-Fi network SSID $SSID = (Get-NetConnectionProfile).Name } @@ -9120,7 +9130,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) $Extension ) - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $OrigProgID = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null) if ($OrigProgID) { @@ -9128,7 +9138,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) $Script:RegisteredProgIDs += $OrigProgID } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null) -ne "") { # Save possible ProgIds history with extension @@ -9144,7 +9154,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # If ProgId doesn't exist set the specified ProgId for the extensions - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if (-not [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null)) { if (-not (Test-Path -Path "HKCU:\Software\Classes\$Extension")) @@ -9162,7 +9172,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force # Set the system ProgId to the extension parameters for File Explorer to the possible options for the assignment, and if absent set the specified ProgId - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ($OrigProgID) { if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids")) @@ -9230,7 +9240,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # Setting a block on changing the UserChoice section - # Due to "Set-StrictMode -Version Latest" we have to use OpenSubKey() + # We have to use OpenSubKey() due to "Set-StrictMode -Version Latest" $OpenSubKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\UserChoice", "ReadWriteSubTree", "TakeOwnership") if ($OpenSubKey) { @@ -9263,7 +9273,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) ) # If there is the system extension ProgId, write it to the already configured by default - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null)) { if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds)) @@ -9274,7 +9284,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # Setting 'NoOpenWith' for all registered the extension ProgIDs - # Due to "Set-StrictMode -Version Latest" we have to check everything + # We have to check everything due to "Set-StrictMode -Version Latest" if (Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore) { [psobject]$OpenSubkey = (Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore).Property @@ -9303,18 +9313,18 @@ public static int UnloadHive(RegistryHives hive, string subKey) } } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap", $Extension, $null)) { $picture = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore).$Extension } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PBrush\CLSID", "", $null)) { $PBrush = (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore)."(default)" } - # Due to "Set-StrictMode -Version Latest" we have to check everything + # We have to check everything due to "Set-StrictMode -Version Latest" if (Get-Variable -Name picture -ErrorAction Ignore) { if (($picture -eq "picture") -and $PBrush) @@ -9323,7 +9333,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if (([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap", $Extension, $null)) -eq "picture") { $Script:RegisteredProgIDs += "PBrush" @@ -13847,6 +13857,10 @@ function WindowsScriptHost # Skip if a scheduled task exists if ($_.State -eq "Ready") { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + break } } @@ -15225,7 +15239,7 @@ public static void PostMessage() } } - # Apply policies found in registry to re-build database database due to gpedit.msc relies in its own database + # Apply policies found in registry to re-build database database because gpedit.msc relies in its own database if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt")) { if (Test-Path -Path "$env:TEMP\Computer.txt") @@ -15280,7 +15294,7 @@ public static void PostMessage() $taskschd_Process_ID = (Get-CimInstance -ClassName CIM_Process | Where-Object -FilterScript {$_.Name -eq "mmc.exe"} | Where-Object -FilterScript { $_.CommandLine -match "taskschd.msc" }).Handle - # Due to "Set-StrictMode -Version Latest" we have to check before executing + # We have to check before executing due to "Set-StrictMode -Version Latest" if ($taskschd_Process_ID) { Get-Process -Id $taskschd_Process_ID | Stop-Process -Force diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index 93861062..de6936ba 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 @@ -577,7 +577,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); $Script:DefenderProductState = $true # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender", "DisableAntiSpyware", $null) -eq 1) { $Script:AntiSpywareEnabled = $false @@ -588,7 +588,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableRealtimeMonitoring", $null) -eq 1) { $Script:RealtimeMonitoringEnabled = $false @@ -599,7 +599,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableBehaviorMonitoring", $null) -eq 1) { $Script:BehaviorMonitoringEnabled = $false @@ -3382,7 +3382,7 @@ function SearchHighlights "Hide" { # Checking whether "Ask Copilot" and "Find results in Web" were disabled. They also disable Search Highlights automatically - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $BingSearchEnabled = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search", "BingSearchEnabled", $null)) $DisableSearchBoxSuggestions = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableSearchBoxSuggestions", $null)) if (($BingSearchEnabled -eq 1) -or ($DisableSearchBoxSuggestions -eq 1)) @@ -6454,7 +6454,7 @@ function NetworkAdaptersSavePower $InterfaceIndex = (Get-CimInstance -ClassName Win32_NetworkAdapter -Namespace root/CIMV2 | Where-Object -FilterScript {$_.NetConnectionStatus -eq 2}).InterfaceIndex if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and ($_.PhysicalMediaType -eq "Native 802.11") -and ($_.InterfaceIndex -eq $InterfaceIndex)}) { - # Get Currently connected Wi-Fi network SSID + # Get currently connected Wi-Fi network SSID $SSID = (Get-NetConnectionProfile).Name } @@ -8579,7 +8579,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) $Extension ) - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $OrigProgID = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null) if ($OrigProgID) { @@ -8587,7 +8587,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) $Script:RegisteredProgIDs += $OrigProgID } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null) -ne "") { # Save possible ProgIds history with extension @@ -8603,7 +8603,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # If ProgId doesn't exist set the specified ProgId for the extensions - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if (-not [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null)) { if (-not (Test-Path -Path "HKCU:\Software\Classes\$Extension")) @@ -8621,7 +8621,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force # Set the system ProgId to the extension parameters for File Explorer to the possible options for the assignment, and if absent set the specified ProgId - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ($OrigProgID) { if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids")) @@ -8689,7 +8689,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # Setting a block on changing the UserChoice section - # Due to "Set-StrictMode -Version Latest" we have to use OpenSubKey() + # We have to use OpenSubKey() due to "Set-StrictMode -Version Latest" $OpenSubKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\UserChoice", "ReadWriteSubTree", "TakeOwnership") if ($OpenSubKey) { @@ -8722,7 +8722,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) ) # If there is the system extension ProgId, write it to the already configured by default - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null)) { if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds)) @@ -8733,7 +8733,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # Setting 'NoOpenWith' for all registered the extension ProgIDs - # Due to "Set-StrictMode -Version Latest" we have to check everything + # We have to check everything due to "Set-StrictMode -Version Latest" if (Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore) { [psobject]$OpenSubkey = (Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore).Property @@ -8762,18 +8762,18 @@ public static int UnloadHive(RegistryHives hive, string subKey) } } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap", $Extension, $null)) { $picture = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore).$Extension } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PBrush\CLSID", "", $null)) { $PBrush = (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore)."(default)" } - # Due to "Set-StrictMode -Version Latest" we have to check everything + # We have to check everything due to "Set-StrictMode -Version Latest" if (Get-Variable -Name picture -ErrorAction Ignore) { if (($picture -eq "picture") -and $PBrush) @@ -8782,7 +8782,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if (([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap", $Extension, $null)) -eq "picture") { $Script:RegisteredProgIDs += "PBrush" @@ -10927,7 +10927,7 @@ function XboxGameBar <# .SYNOPSIS - Game Bar tips + Xbox Game Bar tips .PARAMETER Disable Disable Xbox Game Bar tips @@ -12857,10 +12857,17 @@ function WindowsScriptHost # Skip if a scheduled task exists if ($_.State -eq "Ready") { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + break } } +111 +pause + if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings")) { New-Item -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings" -Force @@ -14113,7 +14120,7 @@ public static void PostMessage() } } - # Apply policies found in registry to re-build database database due to gpedit.msc relies in its own database + # Apply policies found in registry to re-build database database because gpedit.msc relies in its own database if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt")) { if (Test-Path -Path "$env:TEMP\Computer.txt") @@ -14158,7 +14165,7 @@ public static void PostMessage() $taskschd_Process_ID = (Get-CimInstance -ClassName CIM_Process | Where-Object -FilterScript {$_.Name -eq "mmc.exe"} | Where-Object -FilterScript { $_.CommandLine -match "taskschd.msc" }).Handle - # Due to "Set-StrictMode -Version Latest" we have to check before executing + # We have to check before executing due to "Set-StrictMode -Version Latest" if ($taskschd_Process_ID) { Get-Process -Id $taskschd_Process_ID | Stop-Process -Force diff --git a/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 index 4d3a94cb..b31ba68d 100644 --- a/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 @@ -563,7 +563,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); $Script:DefenderProductState = $true # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender", "DisableAntiSpyware", $null) -eq 1) { $Script:AntiSpywareEnabled = $false @@ -574,7 +574,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableRealtimeMonitoring", $null) -eq 1) { $Script:RealtimeMonitoringEnabled = $false @@ -585,7 +585,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableBehaviorMonitoring", $null) -eq 1) { $Script:BehaviorMonitoringEnabled = $false @@ -3283,7 +3283,7 @@ function SearchHighlights "Hide" { # Checking whether "Ask Copilot" and "Find results in Web" were disabled. They also disable Search Highlights automatically - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $BingSearchEnabled = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search", "BingSearchEnabled", $null)) $DisableSearchBoxSuggestions = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableSearchBoxSuggestions", $null)) if (($BingSearchEnabled -eq 1) -or ($DisableSearchBoxSuggestions -eq 1)) @@ -6004,7 +6004,7 @@ function NetworkAdaptersSavePower $InterfaceIndex = (Get-CimInstance -ClassName Win32_NetworkAdapter -Namespace root/CIMV2 | Where-Object -FilterScript {$_.NetConnectionStatus -eq 2}).InterfaceIndex if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and ($_.PhysicalMediaType -eq "Native 802.11") -and ($_.InterfaceIndex -eq $InterfaceIndex)}) { - # Get Currently connected Wi-Fi network SSID + # Get currently connected Wi-Fi network SSID $SSID = (Get-NetConnectionProfile).Name } @@ -8129,7 +8129,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) $Extension ) - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $OrigProgID = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null) if ($OrigProgID) { @@ -8137,7 +8137,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) $Script:RegisteredProgIDs += $OrigProgID } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null) -ne "") { # Save possible ProgIds history with extension @@ -8153,7 +8153,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # If ProgId doesn't exist set the specified ProgId for the extensions - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if (-not [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null)) { if (-not (Test-Path -Path "HKCU:\Software\Classes\$Extension")) @@ -8171,7 +8171,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force # Set the system ProgId to the extension parameters for File Explorer to the possible options for the assignment, and if absent set the specified ProgId - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ($OrigProgID) { if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids")) @@ -8239,7 +8239,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # Setting a block on changing the UserChoice section - # Due to "Set-StrictMode -Version Latest" we have to use OpenSubKey() + # We have to use OpenSubKey() due to "Set-StrictMode -Version Latest" $OpenSubKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\UserChoice", "ReadWriteSubTree", "TakeOwnership") if ($OpenSubKey) { @@ -8272,7 +8272,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) ) # If there is the system extension ProgId, write it to the already configured by default - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null)) { if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds)) @@ -8283,7 +8283,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # Setting 'NoOpenWith' for all registered the extension ProgIDs - # Due to "Set-StrictMode -Version Latest" we have to check everything + # We have to check everything due to "Set-StrictMode -Version Latest" if (Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore) { [psobject]$OpenSubkey = (Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore).Property @@ -8312,18 +8312,18 @@ public static int UnloadHive(RegistryHives hive, string subKey) } } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap", $Extension, $null)) { $picture = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore).$Extension } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PBrush\CLSID", "", $null)) { $PBrush = (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore)."(default)" } - # Due to "Set-StrictMode -Version Latest" we have to check everything + # We have to check everything due to "Set-StrictMode -Version Latest" if (Get-Variable -Name picture -ErrorAction Ignore) { if (($picture -eq "picture") -and $PBrush) @@ -8332,7 +8332,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if (([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap", $Extension, $null)) -eq "picture") { $Script:RegisteredProgIDs += "PBrush" @@ -12149,6 +12149,10 @@ function WindowsScriptHost # Skip if a scheduled task exists if ($_.State -eq "Ready") { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + break } } @@ -13030,7 +13034,7 @@ public static void PostMessage() } } - # Apply policies found in registry to re-build database database due to gpedit.msc relies in its own database + # Apply policies found in registry to re-build database database because gpedit.msc relies in its own database if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt")) { if (Test-Path -Path "$env:TEMP\Computer.txt") @@ -13075,7 +13079,7 @@ public static void PostMessage() $taskschd_Process_ID = (Get-CimInstance -ClassName CIM_Process | Where-Object -FilterScript {$_.Name -eq "mmc.exe"} | Where-Object -FilterScript { $_.CommandLine -match "taskschd.msc" }).Handle - # Due to "Set-StrictMode -Version Latest" we have to check before executing + # We have to check before executing due to "Set-StrictMode -Version Latest" if ($taskschd_Process_ID) { Get-Process -Id $taskschd_Process_ID | Stop-Process -Force diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 index 563d23c3..b29c5e49 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 @@ -300,6 +300,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.TweakerWarning -f $Tweaker) Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -435,6 +436,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Windows Feature Experience Pack") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -449,6 +451,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f $([WinAPI.GetStrings]::GetString(22029))) Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -462,6 +465,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Store") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -483,6 +487,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f $File) Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -497,6 +502,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -516,6 +522,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -529,6 +536,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -547,6 +555,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -565,6 +574,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -580,7 +590,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); $Script:DefenderProductState = $true # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender", "DisableAntiSpyware", $null) -eq 1) { $Script:AntiSpywareEnabled = $false @@ -591,7 +601,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableRealtimeMonitoring", $null) -eq 1) { $Script:RealtimeMonitoringEnabled = $false @@ -602,7 +612,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Checking whether Microsoft Defender was turned off via GPO - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection", "DisableBehaviorMonitoring", $null) -eq 1) { $Script:BehaviorMonitoringEnabled = $false @@ -3390,7 +3400,7 @@ function SearchHighlights "Hide" { # Checking whether "Ask Copilot" and "Find results in Web" were disabled. They also disable Search Highlights automatically - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $BingSearchEnabled = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search", "BingSearchEnabled", $null)) $DisableSearchBoxSuggestions = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableSearchBoxSuggestions", $null)) if (($BingSearchEnabled -eq 1) -or ($DisableSearchBoxSuggestions -eq 1)) @@ -6464,7 +6474,7 @@ function NetworkAdaptersSavePower $InterfaceIndex = (Get-CimInstance -ClassName Win32_NetworkAdapter -Namespace root/CIMV2 | Where-Object -FilterScript {$_.NetConnectionStatus -eq 2}).InterfaceIndex if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and ($_.PhysicalMediaType -eq "Native 802.11") -and ($_.InterfaceIndex -eq $InterfaceIndex)}) { - # Get Currently connected Wi-Fi network SSID + # Get currently connected Wi-Fi network SSID $SSID = (Get-NetConnectionProfile).Name } @@ -8589,7 +8599,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) $Extension ) - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" $OrigProgID = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null) if ($OrigProgID) { @@ -8597,7 +8607,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) $Script:RegisteredProgIDs += $OrigProgID } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null) -ne "") { # Save possible ProgIds history with extension @@ -8613,7 +8623,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # If ProgId doesn't exist set the specified ProgId for the extensions - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if (-not [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null)) { if (-not (Test-Path -Path "HKCU:\Software\Classes\$Extension")) @@ -8631,7 +8641,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force # Set the system ProgId to the extension parameters for File Explorer to the possible options for the assignment, and if absent set the specified ProgId - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ($OrigProgID) { if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\OpenWithProgids")) @@ -8699,7 +8709,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # Setting a block on changing the UserChoice section - # Due to "Set-StrictMode -Version Latest" we have to use OpenSubKey() + # We have to use OpenSubKey() due to "Set-StrictMode -Version Latest" $OpenSubKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\UserChoice", "ReadWriteSubTree", "TakeOwnership") if ($OpenSubKey) { @@ -8732,7 +8742,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) ) # If there is the system extension ProgId, write it to the already configured by default - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\$Extension", "", $null)) { if (-not (Test-Path -Path Registry::HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\FileAssociations\ProgIds)) @@ -8743,7 +8753,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } # Setting 'NoOpenWith' for all registered the extension ProgIDs - # Due to "Set-StrictMode -Version Latest" we have to check everything + # We have to check everything due to "Set-StrictMode -Version Latest" if (Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore) { [psobject]$OpenSubkey = (Get-Item -Path "Registry::HKEY_CLASSES_ROOT\$Extension\OpenWithProgids" -ErrorAction Ignore).Property @@ -8772,18 +8782,18 @@ public static int UnloadHive(RegistryHives hive, string subKey) } } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap", $Extension, $null)) { $picture = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap -Name $Extension -ErrorAction Ignore).$Extension } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PBrush\CLSID", "", $null)) { $PBrush = (Get-ItemProperty -Path HKLM:\SOFTWARE\Classes\PBrush\CLSID -Name "(default)" -ErrorAction Ignore)."(default)" } - # Due to "Set-StrictMode -Version Latest" we have to check everything + # We have to check everything due to "Set-StrictMode -Version Latest" if (Get-Variable -Name picture -ErrorAction Ignore) { if (($picture -eq "picture") -and $PBrush) @@ -8792,7 +8802,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } } - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + # We have to use GetValue() due to "Set-StrictMode -Version Latest" if (([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap", $Extension, $null)) -eq "picture") { $Script:RegisteredProgIDs += "PBrush" @@ -10891,7 +10901,7 @@ function CortanaAutostart #region Gaming <# .SYNOPSIS - Game Bar + Xbox Game Bar .PARAMETER Disable Disable Xbox Game Bar @@ -10906,7 +10916,7 @@ function CortanaAutostart XboxGameBar -Enable .NOTES - To prevent popping up the "You'll need a new app to open this ms-gamingoverlay" warning, you need to disable the Game Bar app, even if you uninstalled it before + To prevent popping up the "You'll need a new app to open this ms-gamingoverlay" warning, you need to disable the Xbox Game Bar app, even if you uninstalled it before .NOTES Current user @@ -11205,6 +11215,7 @@ function CleanupTask Write-Warning -Message ($Localization.WindowsComponentBroken -f (Get-WindowsCapability -Online -Name VBSCRIPT*).DisplayName) Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -11665,6 +11676,7 @@ function SoftwareDistributionTask Write-Warning -Message ($Localization.WindowsComponentBroken -f (Get-WindowsCapability -Online -Name VBSCRIPT*).DisplayName) Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -12003,6 +12015,7 @@ function TempTask Write-Warning -Message ($Localization.WindowsComponentBroken -f (Get-WindowsCapability -Online -Name VBSCRIPT*).DisplayName) Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message "https://www.microsoft.com/software-download/windows11" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -12874,6 +12887,10 @@ function WindowsScriptHost # Skip if a scheduled task exists if ($_.State -eq "Ready") { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + break } } @@ -14130,7 +14147,7 @@ public static void PostMessage() } } - # Apply policies found in registry to re-build database database due to gpedit.msc relies in its own database + # Apply policies found in registry to re-build database database because gpedit.msc relies in its own database if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt")) { if (Test-Path -Path "$env:TEMP\Computer.txt") @@ -14175,7 +14192,7 @@ public static void PostMessage() $taskschd_Process_ID = (Get-CimInstance -ClassName CIM_Process | Where-Object -FilterScript {$_.Name -eq "mmc.exe"} | Where-Object -FilterScript { $_.CommandLine -match "taskschd.msc" }).Handle - # Due to "Set-StrictMode -Version Latest" we have to check before executing + # We have to check before executing due to "Set-StrictMode -Version Latest" if ($taskschd_Process_ID) { Get-Process -Id $taskschd_Process_ID | Stop-Process -Force