diff --git a/Compile.ps1 b/Compile.ps1 index 83be24067f..f427e3551c 100644 --- a/Compile.ps1 +++ b/Compile.ps1 @@ -73,8 +73,8 @@ Get-ChildItem "functions" -Recurse -File | ForEach-Object { } Update-Progress "Adding: Config *.json" 40 Get-ChildItem "config" | Where-Object {$psitem.extension -eq ".json"} | ForEach-Object { - $json = (Get-Content $psitem.FullName).replace("'","''") - $jsonAsObject = $json | convertfrom-json + $json = (Get-Content $psitem.FullName -Raw) + $jsonAsObject = $json | ConvertFrom-Json # Add 'WPFInstall' as a prefix to every entry-name in 'applications.json' file if ($psitem.Name -eq "applications.json") { @@ -85,12 +85,13 @@ Get-ChildItem "config" | Where-Object {$psitem.extension -eq ".json"} | ForEach- } } - # The replace at the end is required, as without it the output of 'converto-json' will be somewhat weird for Multiline Strings - # Most Notably is the scripts in some json files, making it harder for users who want to review these scripts, which're found in the compiled script - $json = ($jsonAsObject | convertto-json -Depth 3).replace('\r\n',"`r`n") + # Line 90 requires no whitespace inside the here-strings, to keep formatting of the JSON in the final script. + $json = @" +$($jsonAsObject | ConvertTo-Json -Depth 3) +"@ - $sync.configs.$($psitem.BaseName) = $json | convertfrom-json - $script_content.Add($(Write-output "`$sync.configs.$($psitem.BaseName) = '$json' `| convertfrom-json" )) + $sync.configs.$($psitem.BaseName) = $json | ConvertFrom-Json + $script_content.Add($(Write-Output "`$sync.configs.$($psitem.BaseName) = @'`n$json`n'@ `| ConvertFrom-Json" )) } # Read the entire XAML file as a single string, preserving line breaks diff --git a/config/dns.json b/config/dns.json index 6c2ffbbd16..6ba26a766a 100644 --- a/config/dns.json +++ b/config/dns.json @@ -46,5 +46,23 @@ "Secondary": "94.140.15.16", "Primary6": "2a10:50c0::bad1:ff", "Secondary6": "2a10:50c0::bad2:ff" + }, + "dns0.eu_Open":{ + "Primary": "193.110.81.254", + "Secondary": "185.253.5.254", + "Primary6": "2a0f:fc80::ffff", + "Secondary6": "2a0f:fc81::ffff" + }, + "dns0.eu_ZERO":{ + "Primary": "193.110.81.9", + "Secondary": "185.253.5.9", + "Primary6": "2a0f:fc80::9", + "Secondary6": "2a0f:fc81::9" + }, + "dns0.eu_KIDS":{ + "Primary": "193.110.81.1", + "Secondary": "185.253.5.1", + "Primary6": "2a0f:fc80::1", + "Secondary6": "2a0f:fc81::1" } } diff --git a/config/feature.json b/config/feature.json index 10835451f3..137cd9ee81 100644 --- a/config/feature.json +++ b/config/feature.json @@ -313,5 +313,13 @@ "Order": "a083_", "Type": "Button", "ButtonWidth": "300" - } + }, + "WPFWinUtilSSHServer": { + "Content": "Enable OpenSSH Server", + "category": "Remote Access", + "panel": "2", + "Order": "a084_", + "Type": "Button", + "ButtonWidth": "300" + }, } diff --git a/config/tweaks.json b/config/tweaks.json index 157b8d6191..5672916497 100644 --- a/config/tweaks.json +++ b/config/tweaks.json @@ -1600,13 +1600,6 @@ "Value": "0", "OriginalValue": "1" }, - { - "Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge", - "Name": "EdgeEnhanceImagesEnabled", - "Type": "DWord", - "Value": "0", - "OriginalValue": "1" - }, { "Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge", "Name": "PersonalizationReportingEnabled", @@ -1656,13 +1649,6 @@ "Value": "0", "OriginalValue": "1" }, - { - "Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge", - "Name": "EdgeFollowEnabled", - "Type": "DWord", - "Value": "0", - "OriginalValue": "1" - }, { "Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge", "Name": "EdgeShoppingAssistantEnabled", @@ -1726,13 +1712,6 @@ "Value": "0", "OriginalValue": "1" }, - { - "Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge", - "Name": "ConfigureDoNotTrack", - "Type": "DWord", - "Value": "1", - "OriginalValue": "0" - }, { "Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge", "Name": "WalletDonationEnabled", @@ -2430,12 +2409,6 @@ "Order": "a001_", "InvokeScript": [ " - # Check if the user has administrative privileges - if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { - Write-Host \"Please run this script as an administrator.\" - return - } - # Check if System Restore is enabled for the main drive try { # Try getting restore points to check if System Restore is enabled @@ -2690,72 +2663,72 @@ } # Check if OneDrive got Uninstalled if (-not (Test-Path $regPath)) { - Write-Host \"Copy downloaded Files from the OneDrive Folder to Root UserProfile\" - Start-Process -FilePath powershell -ArgumentList \"robocopy '$($OneDrivePath)' '$($env:USERPROFILE.TrimEnd())\\' /mov /e /xj\" -NoNewWindow -Wait + Write-Host \"Copy downloaded Files from the OneDrive Folder to Root UserProfile\" + Start-Process -FilePath powershell -ArgumentList \"robocopy '$($OneDrivePath)' '$($env:USERPROFILE.TrimEnd())\\' /mov /e /xj\" -NoNewWindow -Wait - Write-Host \"Removing OneDrive leftovers\" - Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:localappdata\\Microsoft\\OneDrive\" - Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:localappdata\\OneDrive\" - Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:programdata\\Microsoft OneDrive\" - Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:systemdrive\\OneDriveTemp\" - reg delete \"HKEY_CURRENT_USER\\Software\\Microsoft\\OneDrive\" -f - # check if directory is empty before removing: - If ((Get-ChildItem \"$OneDrivePath\" -Recurse | Measure-Object).Count -eq 0) { - Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$OneDrivePath\" - } + Write-Host \"Removing OneDrive leftovers\" + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:localappdata\\Microsoft\\OneDrive\" + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:localappdata\\OneDrive\" + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:programdata\\Microsoft OneDrive\" + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:systemdrive\\OneDriveTemp\" + reg delete \"HKEY_CURRENT_USER\\Software\\Microsoft\\OneDrive\" -f + # check if directory is empty before removing: + If ((Get-ChildItem \"$OneDrivePath\" -Recurse | Measure-Object).Count -eq 0) { + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$OneDrivePath\" + } - Write-Host \"Remove Onedrive from explorer sidebar\" - Set-ItemProperty -Path \"HKCR:\\CLSID\\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\" -Name \"System.IsPinnedToNameSpaceTree\" -Value 0 - Set-ItemProperty -Path \"HKCR:\\Wow6432Node\\CLSID\\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\" -Name \"System.IsPinnedToNameSpaceTree\" -Value 0 + Write-Host \"Remove Onedrive from explorer sidebar\" + Set-ItemProperty -Path \"HKCR:\\CLSID\\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\" -Name \"System.IsPinnedToNameSpaceTree\" -Value 0 + Set-ItemProperty -Path \"HKCR:\\Wow6432Node\\CLSID\\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\" -Name \"System.IsPinnedToNameSpaceTree\" -Value 0 - Write-Host \"Removing run hook for new users\" - reg load \"hku\\Default\" \"C:\\Users\\Default\\NTUSER.DAT\" - reg delete \"HKEY_USERS\\Default\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\" /v \"OneDriveSetup\" /f - reg unload \"hku\\Default\" + Write-Host \"Removing run hook for new users\" + reg load \"hku\\Default\" \"C:\\Users\\Default\\NTUSER.DAT\" + reg delete \"HKEY_USERS\\Default\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\" /v \"OneDriveSetup\" /f + reg unload \"hku\\Default\" - Write-Host \"Removing autostart key\" - reg delete \"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\" /v \"OneDrive\" /f + Write-Host \"Removing autostart key\" + reg delete \"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\" /v \"OneDrive\" /f - Write-Host \"Removing startmenu entry\" - Remove-Item -Force -ErrorAction SilentlyContinue \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\OneDrive.lnk\" + Write-Host \"Removing startmenu entry\" + Remove-Item -Force -ErrorAction SilentlyContinue \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\OneDrive.lnk\" - Write-Host \"Removing scheduled task\" - Get-ScheduledTask -TaskPath '\\' -TaskName 'OneDrive*' -ea SilentlyContinue | Unregister-ScheduledTask -Confirm:$false + Write-Host \"Removing scheduled task\" + Get-ScheduledTask -TaskPath '\\' -TaskName 'OneDrive*' -ea SilentlyContinue | Unregister-ScheduledTask -Confirm:$false - # Add Shell folders restoring default locations - Write-Host \"Shell Fixing\" - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"AppData\" -Value \"$env:userprofile\\AppData\\Roaming\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Cache\" -Value \"$env:userprofile\\AppData\\Local\\Microsoft\\Windows\\INetCache\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Cookies\" -Value \"$env:userprofile\\AppData\\Local\\Microsoft\\Windows\\INetCookies\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Favorites\" -Value \"$env:userprofile\\Favorites\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"History\" -Value \"$env:userprofile\\AppData\\Local\\Microsoft\\Windows\\History\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Local AppData\" -Value \"$env:userprofile\\AppData\\Local\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"My Music\" -Value \"$env:userprofile\\Music\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"My Video\" -Value \"$env:userprofile\\Videos\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"NetHood\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Network Shortcuts\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"PrintHood\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Printer Shortcuts\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Programs\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Recent\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Recent\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"SendTo\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\SendTo\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Start Menu\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Startup\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Templates\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Templates\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"{374DE290-123F-4565-9164-39C4925E467B}\" -Value \"$env:userprofile\\Downloads\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Desktop\" -Value \"$env:userprofile\\Desktop\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"My Pictures\" -Value \"$env:userprofile\\Pictures\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Personal\" -Value \"$env:userprofile\\Documents\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"{F42EE2D3-909F-4907-8871-4C22FC0BF756}\" -Value \"$env:userprofile\\Documents\" -Type ExpandString - Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"{0DDD015D-B06C-45D5-8C4C-F59713854639}\" -Value \"$env:userprofile\\Pictures\" -Type ExpandString - Write-Host \"Restarting explorer\" - taskkill.exe /F /IM \"explorer.exe\" - Start-Process \"explorer.exe\" + # Add Shell folders restoring default locations + Write-Host \"Shell Fixing\" + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"AppData\" -Value \"$env:userprofile\\AppData\\Roaming\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Cache\" -Value \"$env:userprofile\\AppData\\Local\\Microsoft\\Windows\\INetCache\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Cookies\" -Value \"$env:userprofile\\AppData\\Local\\Microsoft\\Windows\\INetCookies\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Favorites\" -Value \"$env:userprofile\\Favorites\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"History\" -Value \"$env:userprofile\\AppData\\Local\\Microsoft\\Windows\\History\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Local AppData\" -Value \"$env:userprofile\\AppData\\Local\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"My Music\" -Value \"$env:userprofile\\Music\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"My Video\" -Value \"$env:userprofile\\Videos\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"NetHood\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Network Shortcuts\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"PrintHood\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Printer Shortcuts\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Programs\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Recent\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Recent\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"SendTo\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\SendTo\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Start Menu\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Startup\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Templates\" -Value \"$env:userprofile\\AppData\\Roaming\\Microsoft\\Windows\\Templates\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"{374DE290-123F-4565-9164-39C4925E467B}\" -Value \"$env:userprofile\\Downloads\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Desktop\" -Value \"$env:userprofile\\Desktop\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"My Pictures\" -Value \"$env:userprofile\\Pictures\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"Personal\" -Value \"$env:userprofile\\Documents\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"{F42EE2D3-909F-4907-8871-4C22FC0BF756}\" -Value \"$env:userprofile\\Documents\" -Type ExpandString + Set-ItemProperty -Path \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\" -Name \"{0DDD015D-B06C-45D5-8C4C-F59713854639}\" -Value \"$env:userprofile\\Pictures\" -Type ExpandString + Write-Host \"Restarting explorer\" + taskkill.exe /F /IM \"explorer.exe\" + Start-Process \"explorer.exe\" - Write-Host \"Waiting for explorer to complete loading\" - Write-Host \"Please Note - The OneDrive folder at $OneDrivePath may still have items in it. You must manually delete it, but all the files should already be copied to the base user folder.\" - Write-Host \"If there are Files missing afterwards, please Login to Onedrive.com and Download them manually\" -ForegroundColor Yellow - Start-Sleep 5 + Write-Host \"Waiting for explorer to complete loading\" + Write-Host \"Please Note - The OneDrive folder at $OneDrivePath may still have items in it. You must manually delete it, but all the files should already be copied to the base user folder.\" + Write-Host \"If there are Files missing afterwards, please Login to Onedrive.com and Download them manually\" -ForegroundColor Yellow + Start-Sleep 5 } else { - Write-Host \"Something went Wrong during the Unistallation of OneDrive\" -ForegroundColor Red + Write-Host \"Something went Wrong during the Unistallation of OneDrive\" -ForegroundColor Red } " ], @@ -3441,7 +3414,7 @@ "panel": "1", "Order": "a040_", "Type": "Combobox", - "ComboItems": "Default DHCP Google Cloudflare Cloudflare_Malware Cloudflare_Malware_Adult Open_DNS Quad9 AdGuard_Ads_Trackers AdGuard_Ads_Trackers_Malware_Adult", + "ComboItems": "Default DHCP Google Cloudflare Cloudflare_Malware Cloudflare_Malware_Adult Open_DNS Quad9 AdGuard_Ads_Trackers AdGuard_Ads_Trackers_Malware_Adult dns0.eu_Open dns0.eu_ZERO dns0.eu_KIDS", "link": "https://christitustech.github.io/winutil/dev/tweaks/z--Advanced-Tweaks---CAUTION/changedns" }, "WPFAddUltPerf": { diff --git a/docs/userguide.md b/docs/userguide.md index de80eb1900..47a49473d8 100644 --- a/docs/userguide.md +++ b/docs/userguide.md @@ -142,6 +142,10 @@ Open old-school Windows panels directly from WinUtil. Following Panels are avail * System Properties * User Accounts +### Remote Access + +Enables OpenSSH server on your windows machine. + ## Updates --- diff --git a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 index 7fa1986751..ce43ac43c7 100644 --- a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 +++ b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 @@ -146,6 +146,7 @@ function Remove-Packages { $_ -NotLike "*ParentalControls*" -AND $_ -NotLike "*Win32WebViewHost*" -AND $_ -NotLike "*InputApp*" -AND + $_ -NotLike "*DirectPlay*" -AND $_ -NotLike "*AccountsControl*" -AND $_ -NotLike "*AsyncTextService*" -AND $_ -NotLike "*CapturePicker*" -AND diff --git a/functions/private/Invoke-WinUtilSSHServer.ps1 b/functions/private/Invoke-WinUtilSSHServer.ps1 new file mode 100644 index 0000000000..7185af7ed3 --- /dev/null +++ b/functions/private/Invoke-WinUtilSSHServer.ps1 @@ -0,0 +1,81 @@ +function Invoke-WinUtilSSHServer { + <# + .SYNOPSIS + Enables OpenSSH server to remote into your windows device + #> + + # Get the latest version of OpenSSH Server + $FeatureName = Get-WindowsCapability -Online | Where-Object { $_.Name -like "OpenSSH.Server*" } + + # Install the OpenSSH Server feature if not already installed + if ($FeatureName.State -ne "Installed") { + Write-Host "Enabling OpenSSH Server" + Add-WindowsCapability -Online -Name $FeatureName.Name + } + + # Sets up the OpenSSH Server service + Write-Host "Starting the services" + Start-Service -Name sshd + Set-Service -Name sshd -StartupType Automatic + + # Sets up the ssh-agent service + Start-Service 'ssh-agent' + Set-Service -Name 'ssh-agent' -StartupType 'Automatic' + + # Confirm the required services are running + $SSHDaemonService = Get-Service -Name sshd + $SSHAgentService = Get-Service -Name 'ssh-agent' + + if ($SSHDaemonService.Status -eq 'Running') { + Write-Host "OpenSSH Server is running." + } else { + try { + Write-Host "OpenSSH Server is not running. Attempting to restart..." + Restart-Service -Name sshd -Force + Write-Host "OpenSSH Server has been restarted successfully." + } catch { + Write-Host "Failed to restart OpenSSH Server: $_" + } + } + if ($SSHAgentService.Status -eq 'Running') { + Write-Host "ssh-agent is running." + } else { + try { + Write-Host "ssh-agent is not running. Attempting to restart..." + Restart-Service -Name sshd -Force + Write-Host "ssh-agent has been restarted successfully." + } catch { + Write-Host "Failed to restart ssh-agent : $_" + } + } + + #Adding Firewall rule for port 22 + Write-Host "Setting up firewall rules" + $firewallRule = (Get-NetFirewallRule -Name 'sshd').Enabled + if ($firewallRule) { + Write-Host "Firewall rule for OpenSSH Server (sshd) already exists." + } else { + New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 + Write-Host "Firewall rule for OpenSSH Server created and enabled." + } + + # Check for the authorized_keys file + $sshFolderPath = "$env:HOMEDRIVE\$env:HOMEPATH\.ssh" + $authorizedKeysPath = "$sshFolderPath\authorized_keys" + + if (-not (Test-Path -Path $sshFolderPath)) { + Write-Host "Creating ssh directory..." + New-Item -Path $sshFolderPath -ItemType Directory -Force + } + + if (-not (Test-Path -Path $authorizedKeysPath)) { + Write-Host "Creating authorized_keys file..." + New-Item -Path $authorizedKeysPath -ItemType File -Force + Write-Host "authorized_keys file created at $authorizedKeysPath." + } else { + Write-Host "authorized_keys file already exists at $authorizedKeysPath." + } + Write-Host "OpenSSH server was successfully enabled." + Write-Host "The config file can be located at C:\ProgramData\ssh\sshd_config " + Write-Host "Add your public keys to this file -> $authorizedKeysPath" +} diff --git a/functions/private/Set-WinUtilRegistry.ps1 b/functions/private/Set-WinUtilRegistry.ps1 index e3f66e2e3e..397ce84c1c 100644 --- a/functions/private/Set-WinUtilRegistry.ps1 +++ b/functions/private/Set-WinUtilRegistry.ps1 @@ -36,7 +36,12 @@ function Set-WinUtilRegistry { } Write-Host "Set $Path\$Name to $Value" - Set-ItemProperty -Path $Path -Name $Name -Type $Type -Value $Value -Force -ErrorAction Stop | Out-Null + if ($Value -ne ""){ + Set-ItemProperty -Path $Path -Name $Name -Type $Type -Value $Value -Force -ErrorAction Stop | Out-Null + } + else{ + Remove-ItemProperty -Path $Path -Name $Name -Force -ErrorAction Stop | Out-Null + } } catch [System.Security.SecurityException] { Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception" } catch [System.Management.Automation.ItemNotFoundException] { diff --git a/functions/public/Invoke-WPFButton.ps1 b/functions/public/Invoke-WPFButton.ps1 index 2773ccb571..ee4d0421d5 100644 --- a/functions/public/Invoke-WPFButton.ps1 +++ b/functions/public/Invoke-WPFButton.ps1 @@ -58,5 +58,6 @@ function Invoke-WPFButton { "WPFCloseButton" {Invoke-WPFCloseButton} "MicrowinScratchDirBT" {Invoke-ScratchDialog} "WPFWinUtilPSProfile" {Invoke-WinUtilpsProfile} + "WPFWinUtilSSHServer" {Invoke-WinUtilSSHServer} } } diff --git a/functions/public/Invoke-WPFImpex.ps1 b/functions/public/Invoke-WPFImpex.ps1 index 43d835de95..83f1887f2d 100644 --- a/functions/public/Invoke-WPFImpex.ps1 +++ b/functions/public/Invoke-WPFImpex.ps1 @@ -19,44 +19,59 @@ function Invoke-WPFImpex { $Config = $null ) - if ($type -eq "export") { - $FileBrowser = New-Object System.Windows.Forms.SaveFileDialog - } - if ($type -eq "import") { - $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog - } - - if (-not $Config) { - $FileBrowser.InitialDirectory = [Environment]::GetFolderPath('Desktop') - $FileBrowser.Filter = "JSON Files (*.json)|*.json" - $FileBrowser.ShowDialog() | Out-Null + function ConfigDialog { + if (!$Config) { + switch ($type) { + "export" { $FileBrowser = New-Object System.Windows.Forms.SaveFileDialog } + "import" { $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog } + } + $FileBrowser.InitialDirectory = [Environment]::GetFolderPath('Desktop') + $FileBrowser.Filter = "JSON Files (*.json)|*.json" + $FileBrowser.ShowDialog() | Out-Null - if($FileBrowser.FileName -eq "") { - return + if ($FileBrowser.FileName -eq "") { + return $null + } else { + return $FileBrowser.FileName + } } else { - $Config = $FileBrowser.FileName + return $Config } } - if ($type -eq "export") { - $jsonFile = Get-WinUtilCheckBoxes -unCheck $false - $jsonFile | ConvertTo-Json | Out-File $FileBrowser.FileName -Force - $runscript = "iex ""& { `$(irm christitus.com/win) } -Config '$($FileBrowser.FileName)'""" - $runscript | Set-Clipboard - } - if ($type -eq "import") { - $jsonFile = Get-Content $Config | ConvertFrom-Json - - $flattenedJson = @() - $jsonFile.PSObject.Properties | ForEach-Object { - $category = $_.Name - foreach ($checkboxName in $_.Value) { - if ($category -ne "Install") { - $flattenedJson += $checkboxName + switch ($type) { + "export" { + try { + $Config = ConfigDialog + if ($Config) { + $jsonFile = Get-WinUtilCheckBoxes -unCheck $false | ConvertTo-Json + $jsonFile | Out-File $Config -Force + "iex ""& { `$(irm christitus.com/win) } -Config '$Config'""" | Set-Clipboard } + } catch { + Write-Error "An error occurred while exporting: $_" + } + } + "import" { + try { + $Config = ConfigDialog + if ($Config) { + try { + if ($Config -match '^https?://') { + $jsonFile = (Invoke-WebRequest "$Config").Content | ConvertFrom-Json + } else { + $jsonFile = Get-Content $Config | ConvertFrom-Json + } + } catch { + Write-Error "Failed to load the JSON file from the specified path or URL: $_" + return + } + $flattenedJson = $jsonFile.PSObject.Properties.Where({ $_.Name -ne "Install" }).ForEach({ $_.Value }) + Invoke-WPFPresets -preset $flattenedJson -imported $true + } + } catch { + Write-Error "An error occurred while importing: $_" } } - - Invoke-WPFPresets -preset $flattenedJson -imported $true } } diff --git a/tools/Invoke-Preprocessing.ps1 b/tools/Invoke-Preprocessing.ps1 index 090dd17818..0569bc3565 100644 --- a/tools/Invoke-Preprocessing.ps1 +++ b/tools/Invoke-Preprocessing.ps1 @@ -72,80 +72,45 @@ function Invoke-Preprocessing { throw "[Invoke-Preprocessing] Invalid Paramter Value for 'WorkingDir', passed value: '$WorkingDir'. Either the path is a File or Non-Existing/Invlid, please double check your code." } - $count = $ExcludedFiles.Count - - # Make sure there's a * at the end of folders in ExcludedFiles list - for ($i = 0; $i -lt $count; $i++) { - $excludedFile = $ExcludedFiles[$i] - $isFolder = ($excludedFile) -match '\\$' - if ($isFolder) { $ExcludedFiles[$i] = $excludedFile + '*' } + $InternalExcludedFiles = [System.Collections.Generic.List[string]]::new($ExcludedFiles.Count) + ForEach ($excludedFile in $ExcludedFiles) { + $InternalExcludedFiles.Add($excludedFile) | Out-Null } - # Validate the ExcludedFiles List before continuing on, - # that's if there's a list in the first place, and '-SkipExcludedFilesValidation' was not provided. - if (-not $SkipExcludedFilesValidation) { - for ($i = 0; $i -lt $count; $i++) { - $excludedFile = $ExcludedFiles[$i] + # Validate the ExcludedItems List before continuing on, + # that's if there's a list in the first place, and '-SkipInternalExcludedFilesValidation' was not provided. + if ($ExcludedFiles.Count -gt 0) { + ForEach ($excludedFile in $ExcludedFiles) { $filePath = "$(($WorkingDir -replace ('\\$', '')) + '\' + ($excludedFile -replace ('\.\\', '')))" - - # Handle paths with wildcards in a different implementation - $matches = ($filePath) -match '^.*?\*' - - if ($matches) { - if (-NOT (Get-ChildItem -Recurse -Path "$filePath" -File -Force)) { - $failedFilesList += "'$filePath', " + $files = Get-ChildItem -Recurse -Path "$filePath" -File -Force + if ($files.Count -gt 0) { + ForEach ($file in $files) { + $InternalExcludedFiles.Add("$($file.FullName)") | Out-Null } - } else { - if (-NOT (Test-Path -Path "$filePath")) { - $failedFilesList += "'$filePath', " - } - } + } else { $failedFilesList += "'$filePath', " } } $failedFilesList = $failedFilesList -replace (',\s*$', '') - if (-NOT $failedFilesList -eq "") { + if ((-not $failedFilesList -eq "") -and (-not $SkipExcludedFilesValidation)) { throw "[Invoke-Preprocessing] One or more File Paths and/or File Patterns were not found, you can use '-SkipExcludedFilesValidation' switch to skip this check, the failed to validate are: $failedFilesList" } } # Get Files List - [System.Collections.ArrayList]$files = Get-ChildItem $WorkingDir -Recurse -Exclude $ExcludedFiles -File -Force - $numOfFiles = $files.Count + [System.Collections.ArrayList]$files = Get-ChildItem -LiteralPath $WorkingDir -Recurse -Exclude $InternalExcludedFiles -File -Force # Only keep the 'FullName' Property for every entry in the list - for ($i = 0; $i -lt $numOfFiles; $i++) { + for ($i = 0; $i -lt $files.Count; $i++) { $file = $files[$i] $files[$i] = $file.FullName } # If a file(s) are found in Exclude List, # Remove the file from files list. - for ($j = 0; $j -lt $excludedFiles.Count; $j++) { - # Prepare some variables - $excluded = $excludedFiles[$j] - $pathToFind = ($excluded) -replace ('^\.\\', '') - $pathToFind = $WorkingDir + '\' + $pathToFind - $index = -1 # reset index on every iteration - - # Handle paths with wildcards in a different implementation - $matches = ($pathToFind) -match '^.*?\*' - - if ($matches) { - $filesToCheck = Get-ChildItem -Recurse -Path "$pathToFind" -File -Force - if ($filesToCheck) { - for ($k = 0; $k -lt $filesToCheck.Count; $k++) { - $fileToCheck = $filesToCheck[$k] - $index = $files.IndexOf("$fileToCheck") - if ($index -ge 0) { $files.RemoveAt($index) } - } - } - } else { - $index = $files.IndexOf("$pathToFind") - if ($index -ge 0) { $files.RemoveAt($index) } - } + ForEach ($excludedFile in $InternalExcludedFiles) { + $index = $files.IndexOf("$excludedFile") + if ($index -ge 0) { $files.RemoveAt($index) } } - # Make sure 'numOfFiles' is synced with the actual Number of Files found in '$files' - # This's done because previous may or may not edit the files list, so we should update it $numOfFiles = $files.Count if ($numOfFiles -eq 0) {