[PowerShell] Windows 10 Sophia Script

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

  1. farag

    farag MDL Junior Member

    Apr 1, 2014
    72
    90
    0
    #1 farag, May 8, 2020
    Last edited: Nov 12, 2020
    Windows 10 Sophia Script
    A module for OS fine-tuning and automating the routine tasks.

    Core features:
    • Set up Privacy & Telemetry;
    • Turn off diagnostics tracking scheduled tasks;
    • Set up UI & Personalization;
    • Uninstall OneDrive "correctly";
    • Interactive prompts;
    • Change %TEMP% environment variable path to %SystemDrive%\Temp
    • Change location of the user folders programmatically (without moving user files) within interactive menu using up/down arrows and Enter key to make a selection
      • "Desktop";
      • "Documents";
      • "Downloads";
      • "Music";
      • "Pictures"
      • "Videos.
    • Uninstall UWP apps from all accounts with exception apps list with pop-up form written in WPF;
    • Turn off Windows features;
    • Remove Windows capabilities with pop-up form written in WPF;
    • Create a Windows cleaning up task in the Task Scheduler;
    • Create tasks in the Task Scheduler to clear
      • %SystemRoot%\SoftwareDistribution\Download
      • %TEMP%
    • Unpin all Start menu tiles;
    • Pin shortcuts to Start menu using syspin.exe
      • Three shortcuts are preconfigured to be pinned: Control Panel, "old style" Devices and Printers, and Command Prompt
    • Turn on Controlled folder access and add protected folders;
    • Add exclusion folder from Microsoft Defender Antivirus scanning
    • Add exclusion file from Microsoft Defender Antivirus scanning
    • Refresh desktop icons, environment variables and taskbar without restarting File Explorer;
    • Many more File Explorer and context menu "deep" tweaks.


    [​IMG]
    [​IMG]
    [​IMG]

    Windows 10 Sophia Script
    2004 (20H1)/2009 (20H2): v5.2

    Windows 10 Setup Script
    1903 — 1909: v4.5 (deprecated/outdated)
    LTSC: v4.5

    Download from Github

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

    Donate: https://ko-fi.com/farag
     
  2. Mr.X

    Mr.X MDL Guru

    Jul 14, 2013
    7,068
    14,695
    240
  3. farag

    farag MDL Junior Member

    Apr 1, 2014
    72
    90
    0
  4. farag

    farag MDL Junior Member

    Apr 1, 2014
    72
    90
    0
    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
    20
    0
    0
    Thank You so much
     
  6. farag

    farag MDL Junior Member

    Apr 1, 2014
    72
    90
    0
    #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
    20
    0
    0
    #7 denslin, May 22, 2020
    Last edited: May 23, 2020
    Thank so much. VERY GOOD!!
     
  8. farag

    farag MDL Junior Member

    Apr 1, 2014
    72
    90
    0
    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 Junior Member

    Apr 1, 2014
    72
    90
    0
  10. drew84

    drew84 MDL Addicted

    Mar 13, 2014
    743
    1,217
    30
  11. farag

    farag MDL Junior Member

    Apr 1, 2014
    72
    90
    0
    Thanks. Copy/paste )))
     
  12. farag

    farag MDL Junior Member

    Apr 1, 2014
    72
    90
    0
  13. drew84

    drew84 MDL Addicted

    Mar 13, 2014
    743
    1,217
    30
    #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 Junior Member

    Apr 1, 2014
    72
    90
    0
    @drew84, I'll check.on monday. )
     
  15. farag

    farag MDL Junior Member

    Apr 1, 2014
    72
    90
    0
    #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 Addicted

    Mar 13, 2014
    743
    1,217
    30
    #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 Junior Member

    Apr 1, 2014
    72
    90
    0
    @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
    33
    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 Addicted

    Mar 13, 2014
    743
    1,217
    30
    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 Junior Member

    Apr 1, 2014
    72
    90
    0
    v4.5.3