[PowerShell] Sophia Script for Windows 10 & Windows 11 | 5.17.8 | 6.5.8 | x64 2023

Discussion in 'Scripting' started by farag, May 8, 2020.

  1. farag

    farag MDL Member

    Apr 1, 2014
    238
    352
    10
    #1 farag, May 8, 2020
    Last edited: Dec 13, 2023
    Sophia.png

    Logo by teahea


    Sophia Script for Windows
    A module for Windows fine-tuning and automating the routine tasks.

    Core features:

    • * Set up Privacy & Telemetry;
      * Enable DNS-over-HTTPS for IPv4;
      * Turn off diagnostics tracking scheduled tasks with pop-up form written in WPF;
      * Set up UI & Personalization;
      * Uninstall OneDrive "correctly";
      * Interactive prompts;
      * The TAB completion for functions and their arguments (if using the Functions.ps1 file);
      * Change %TEMP% environment variable path to %SystemDrive%\Temp;
      * Change location of the user folders programmatically (without moving user files) within interactive menu using arrows to select a drive
      * "Desktop"
      * "Documents"
      * "Downloads"
      * "Music"
      * "Pictures"
      * "Videos"
      * Install free (light and dark) "Windows 11 Cursors Concept v2" cursors from Jepri Creations on-the-fly;
      * Uninstall UWP apps displaying packages names;
      * Generate installed UWP apps list dynamically
      * Restore the default uninstalled UWP apps for current user displaying localized packages names;
      * The TAB autocompletion for function and its' arguments by typing first letters;
      * Disable Windows features displaying friendly packages names with pop-up form written in WPF;
      * Uninstall Windows capabilities displaying friendly packages names with pop-up form written in WPF;
      * Download and install the HEVC Video Extensions from Device Manufacturer to be able to open HEVC format;
      * Register app, calculate hash, and set as default for specific extension without the "How do you want to open this" pop-up using special function;
      * Export all Windows associations. Associations will be exported as Application_Associations.json file in script root folder;
      * Import exported JSON file after a clean installation. You have to install all apps according to an exported JSON file to restore all associations;
      * Install any supported Linux distrobution for WSL displaying friendly distro names with pop-up form written in WPF;
      * Create a Windows Cleanup and Windows Cleanup Notification scheduled tasks for Windows cleaning up unused files and updates;
      * A native toast notification will be displayed where you can choose to snooze, run the cleanup task or dismiss;
      * Create tasks in the Task Scheduler to clear
      * %SystemRoot%\SoftwareDistribution\Download
      * %TEMP%
      * Pin shortcuts to Start via pure PowerShell
      * Three shortcuts are pre-configured to be pinned: Control Panel, "old style" Devices and Printers.
      * Unpin all Start menu tiles;
      * Turn on Controlled folder access and add protected folders using dialog menu;
      * Add exclusion folder from Microsoft Defender Antivirus scanning using dialog menu;
      * Add exclusion file from Microsoft Defender Antivirus scanning using dialog menu;
      * Refresh desktop icons, environment variables and taskbar without restarting File Explorer;
      * Configure the Windows security;
      * Display all policy registry keys (even manually created ones) in the Local Group Policy Editor snap-in (gpedit.msc);
      * Many more File Explorer and context menu "deep" tweaks.



    Download from Github

    The full changelog for all years

    If you find bugs or bad translation, feel free to report it to me.

    Donate: https://yoomoney.ru/to/4100116615568835
     
  2. Mr.X

    Mr.X MDL Guru

    Jul 14, 2013
    8,575
    15,645
    270
  3. farag

    farag MDL Member

    Apr 1, 2014
    238
    352
    10
  4. farag

    farag MDL Member

    Apr 1, 2014
    238
    352
    10
    Updated up to the v4.2.1 version.
    • Now the form for removing capabilities and UWP apps will not be initialized if there are no elements for removal;
    • Added for the all tasks in the Task Scheduler a description displayed in the "Description" section;
    • Fixed bug in "Include command line in process creation events" section
    • Minor changes;
    • Also you can test [20H1 version](https://gist.github.com/farag2/5a6d9952247aefe42ba81a9d95507765).
     
  5. denslin

    denslin MDL Novice

    Oct 29, 2009
    21
    0
    0
    Thank You so much
     
  6. farag

    farag MDL Member

    Apr 1, 2014
    238
    352
    10
    #6 farag, May 21, 2020
    Last edited: May 23, 2020
    (OP)
    Updated up to the v4.3 version.
    • Fixed bug in "Show accent color on Start, taskbar, and action center" section;
    • The "Change location of the user folders" section was rewritten into interactive menu using up/down arrows and Enter key to make a selection (menu by MaxKozlov)
      • A user will be prompted to select the drive letter where the user folders will be moved programmatically
      • Files will not be moved. Do it manually
      • Video
    • The task "Update cleanup" in the Task Scheduler renamed into "Windows Cleanup";
    • Comments;
    • Minor changes;
    • Also you can test 20H1 version
     
  7. denslin

    denslin MDL Novice

    Oct 29, 2009
    21
    0
    0
    #7 denslin, May 22, 2020
    Last edited: May 23, 2020
    Thank so much. VERY GOOD!!
     
  8. farag

    farag MDL Member

    Apr 1, 2014
    238
    352
    10
    v4.4 released!
    • Updated links in the comment-based help section;
    • Updated "Increase taskbar transparency" section
      • Removed "ForceEffectMode" key, that blocked Windows 10 transparency effects
      • To remove unnecessary key, execute
      PHP:
      # Restart needed
       
      Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\Dwm -Name ForceEffectMode -Force
    • Updated "Change location of the user folders" section
      • Added comment-based section;
      • Added the ability to skip (#25)
    • Updated "Uninstall UWP apps" section
      • Added "Uninstall for All Users" button to the form (unchecked by default) (@oz-zo) to uninstall UWP apps from all accounts
    • Add the "Run as different user" item to the .exe files types context menu
      • Removed unnecessary keys
    • Comments;
    • Minor changes;
    • Also you can test 20H1 version.
     
  9. farag

    farag MDL Member

    Apr 1, 2014
    238
    352
    10
  10. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,347
    2,302
    60
  11. farag

    farag MDL Member

    Apr 1, 2014
    238
    352
    10
    Thanks. Copy/paste )))
     
  12. farag

    farag MDL Member

    Apr 1, 2014
    238
    352
    10
  13. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,347
    2,302
    60
    #13 drew84, Jun 19, 2020
    Last edited: Jun 19, 2020
    @farag Hello,
    In the process of getting ready for a fresh install
    So deceided to give this script a tryout (albeit NOT on a fresh install)

    Code:
    Restore point
    To create a restore point enter the required letter
    [C] Create  [D] Do not create  [S] Skip  [?] Help (default is "S"):
    VERBOSE: Skipped
    
    ... all good until

    Capability Packages Removal
    ----------------------------------------
    Code:
    VERBOSE: Form opening...
    
    None Selected, Closed Form -> Script Continues

    App Packages Removal
    --------------------------------
    Code:
    VERBOSE: Form opening...
    
    None Selected, Closed Form -> Script Stops FIRST Issue

    .... unless an app is selected for removal, so for testing, selected GetHelp and GetStarted

    Then script continues SECOND Issue
    Code:
    VERBOSE: Performing the operation "Remove package" on target "Microsoft.Xbox.TCUI_1.11.29001.0_neutral_~_8wekyb3d8bbwe".
    Remove-AppxPackage : Removal failed. Please contact your software vendor.
    Deployment Remove operation with target volume C: on Package Microsoft.Xbox.TCUI_1.11.29001.0_neutral_~_8wekyb3d8bbwe from:   failed with error
    0x80070002. See http://go.microsoft.com/fwlink/?LinkId=235160 for help diagnosing app deployment issues.
    At D:\Win.10.2004.4.5.1-17.06.2020\Win 10 2004.ps1:2472 char:120
    + ... me -cmatch $XboxAppxPackages} | Remove-AppxPackage -AllUsers -Verbose
    +                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Remove-AppxPackage], COMException
        + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.Windows.Appx.PackageManager.Commands.RemoveAppxPackageCommand
    
    TCUI Package was not amongst those selected for removal

    Then continues
    Code:
    Line Errors/Warnings
    
     886 This configuration is managed by an Administrator. Access is denied.
    2472 Removal failed. Please contact your software vendor.
    
         Deployment Remove operation with target volume C: on Package Microsoft.Xbox.TCUI_1.11.29001.0_neutral_~_8wekyb3d8bbwe from:   failed with error
         0x80070002. See http://go.microsoft.com/fwlink/?LinkId=235160 for help diagnosing app deployment issues.
    
    
    PS C:\WINDOWS\system32>
    
    ... again referring to TCUI package that was not selected for removal (SECOND Issue).

    Script will not continue beyond this point... THIRD Issue

    will have a look again, but would appreciate any comments
     
  14. farag

    farag MDL Member

    Apr 1, 2014
    238
    352
    10
    @drew84, I'll check.on monday. )
     
  15. farag

    farag MDL Member

    Apr 1, 2014
    238
    352
    10
    #15 farag, Jun 22, 2020
    Last edited: Jun 22, 2020
    (OP)
    @drew84, I tried to reproduced those issues... and failed with every ones. I've concluded something wrong with your OS. As we can see on a screenshot
    Code:
    This configuration is managed by an Administrator. Access is denied.
    something went wrong. And even MS indicates the error
    Code:
    http://go.microsoft.com/fwlink/?LinkId=235160
    You need to dig into logs mentioned in the link.
    P.S. I'd advice to check OS health
    Code:
    DISM /Online /Cleanup-Image /RestoreHealth
    sfc /scannow
     
  16. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,347
    2,302
    60
    #16 drew84, Jun 22, 2020
    Last edited: Jun 22, 2020
    @farag
    thanks for reply.. OS is OK believe you me, Windows? not so sure, but lived with it for so long now am not going to abandon it
    the 0x80070002 error does not exist on that page, however the issue can usually be resolved by deleting the Software Distribution Folder.. and running the script again

    ... the access denied is nothing more than an issue with security settings in GPO.. that I can understand, so not a problem
    what is a problem (the 2nd one that I raised) is that the script is attempting to remove a package that was not expressly selected for removal.
    in other words it shouldn't be removing it in the first place.

    a brief history...
    I currently use GodHand's Optimize-Offline Script for servicing my images prior to installation (which serves me well),
    note: I do adapt his script extensively to suit my preferences, some of which can be seen in the O-O thread here at MDL.


    However I wanted to look (again) into an online method as an alternative.

    I had noticed that you had made some suggestions for Disassembler0's script (which I used prior to adopting O-O), and
    as GodHand himself forked an original incarnation of your script on his GitHub page, I deceided to focus my attention on your script


    ... My original post was far more extensive, but I had to reduce it due to character limitations

    In the original, I covered the fact that I was running the script on a working (Optimized) install (not a fresh one)
    so I was expecting some adverse circumstances.. but nothing that can explain the issue at the start of this post.

    ... as an added note, I will be persevering with your script, so not giving up
     
  17. farag

    farag MDL Member

    Apr 1, 2014
    238
    352
    10
    @drew84, sorry but I couldn't reproduced issue #2 again. All is beding uninstalled fine: with any selection conditions. Nonetheless I've tested the script on hundreds PC and never faced that issue (but faced many more :D)
    So I do not know even what to write in Russian, not like in English )
     
  18. Trickz

    Trickz MDL Novice

    Jul 31, 2015
    35
    11
    0
    In my case it want's to remove cortana package every time doesn't matter if you uncheck it.
    I also had some problems testing it on a already serviced image with some capabilities and packages removed, it hangs trying to remove stuff that was already removed before.
    On an untouched image it works good but still want's to remove some packages you uncheck. I don't remember which exactly beside cortana, it was few days ago and i tried many different scripts to use for a fresh 20h1 install.
     
  19. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,347
    2,302
    60
    I personally think that running the script on an altready Optimized (and used) OS is the main reason for the issue,
    but can't really say; until I give it a proper run out on a fresh install.. hopefully soon.

    When it comes to using Scripts, I am only really interested in ones that are frequently maintained (Up to Date with current OS)
    As regards that, @GodHand's (Offline) and @farag's (Online) scripts are the only ones that meet my criteria, with the added bonus that they both are here at MDL
     
  20. farag

    farag MDL Member

    Apr 1, 2014
    238
    352
    10
    v4.5.3