Browse Source

Improved OneDrive function

pull/450/head
Dmitry Nefedov 2 years ago
parent
commit
b09d58efa6
  1. 2
      CHANGELOG.md
  2. 12
      sophia_script_versions.json
  3. 8
      src/Sophia_Script_for_Windows_10/Functions.ps1
  4. 2
      src/Sophia_Script_for_Windows_10/Manifest/Sophia.psd1
  5. 51
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  6. 10
      src/Sophia_Script_for_Windows_10/Sophia.ps1
  7. 8
      src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1
  8. 2
      src/Sophia_Script_for_Windows_10_LTSC_2019/Manifest/Sophia.psd1
  9. 2
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  10. 10
      src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1
  11. 8
      src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1
  12. 2
      src/Sophia_Script_for_Windows_10_LTSC_2021/Manifest/Sophia.psd1
  13. 2
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  14. 10
      src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1
  15. 8
      src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1
  16. 2
      src/Sophia_Script_for_Windows_10_PowerShell_7/Manifest/Sophia.psd1
  17. 51
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  18. 10
      src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1
  19. 8
      src/Sophia_Script_for_Windows_11/Functions.ps1
  20. 2
      src/Sophia_Script_for_Windows_11/Manifest/Sophia.psd1
  21. 49
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  22. 10
      src/Sophia_Script_for_Windows_11/Sophia.ps1
  23. 8
      src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1
  24. 2
      src/Sophia_Script_for_Windows_11_PowerShell_7/Manifest/Sophia.psd1
  25. 49
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1
  26. 10
      src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

2
CHANGELOG.md

@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 5.15.0 | 6.3.0 — 30.01.2023
## 5.15.1 | 6.3.1 — 30.01.2023
* Added new function to prevent Microsoft Edge desktop shortcut creation upon its' update;
* By default it prevents for all Microsofot Edge channels (with checks if any of them is installed): `PreventEdgeShortcutCreation -Channels Stable, Beta, Dev, Canary`.

12
sophia_script_versions.json

@ -1,9 +1,9 @@
{
"Sophia_Script_Windows_10_PowerShell_5_1": "5.15.0",
"Sophia_Script_Windows_10_PowerShell_7": "5.15.0",
"Sophia_Script_Windows_10_LTSC2019": "5.5.0",
"Sophia_Script_Windows_10_LTSC2021": "5.15.0",
"Sophia_Script_Windows_11_PowerShell_5_1": "6.3.0",
"Sophia_Script_Windows_11_PowerShell_7": "6.3.0",
"Sophia_Script_Windows_10_PowerShell_5_1": "5.15.1",
"Sophia_Script_Windows_10_PowerShell_7": "5.15.1",
"Sophia_Script_Windows_10_LTSC2019": "5.5.1",
"Sophia_Script_Windows_10_LTSC2021": "5.15.1",
"Sophia_Script_Windows_11_PowerShell_5_1": "6.3.1",
"Sophia_Script_Windows_11_PowerShell_7": "6.3.1",
"Sophia_Script_Wrapper": "2.6.1"
}

8
src/Sophia_Script_for_Windows_10/Functions.ps1

@ -2,7 +2,7 @@
.SYNOPSIS
The TAB completion for functions and their arguments
Version: v5.15.0
Version: v5.15.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -44,13 +44,13 @@ function Sophia
Invoke-Expression -Command $Function
}
# The "RefreshEnvironment" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {RefreshEnvironment; Errors}
# The "PostActions" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {PostActions; Errors}
}
Clear-Host
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.15.0 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.15.1 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force

2
src/Sophia_Script_for_Windows_10/Manifest/Sophia.psd1

@ -1,6 +1,6 @@
@{
RootModule = '..\Module\Sophia.psm1'
ModuleVersion = '5.15.0'
ModuleVersion = '5.15.1'
GUID = '109cc881-c42b-45af-a74a-550781989d6a'
Author = 'Dmitry "farag" Nefedov'
Copyright = '(c) 2014—2023 farag & Inestic. All rights reserved'

51
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -2,7 +2,7 @@
.SYNOPSIS
Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks
Version: v5.15.0
Version: v5.15.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -4436,8 +4436,25 @@ function OneDrive
"Uninstall"
{
[string]$UninstallString = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -ErrorAction Ignore | ForEach-Object -Process {$_.Meta.Attributes["UninstallString"]}
if ($UninstallString)
if (-not $UninstallString)
{
# OneDrive is not installed
return
}
# Check if script was launched from OneDrive folder and preset file has function to uninstall OneDrive
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and ($_.Text -eq "OneDrive -Uninstall") -or ($_.Text -match "Invoke-Expression")
}
# Check if user is logged into OneDrive account (Microsoft account)
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($PresetName -and $UserEmail)
{
# Exit if user accidentelly set function in preset to uninstall but he's logged into the app
return
}
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.OneDriveUninstalling -Verbose
@ -4457,7 +4474,7 @@ function OneDrive
# Get the OneDrive user folder path and remove it if it doesn't contain any user files
if (Test-Path -Path $env:OneDrive)
{
if ((Get-ChildItem -Path $env:OneDrive | Measure-Object).Count -eq 0)
if ((Get-ChildItem -Path $env:OneDrive -ErrorAction Ignore | Measure-Object).Count -eq 0)
{
Remove-Item -Path $env:OneDrive -Recurse -Force -ErrorAction Ignore
@ -4516,10 +4533,6 @@ public static bool MarkFileDelete (string sourcefile)
# Getting the OneDrive folder path
$OneDriveFolder = Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)
# Save all opened folders in order to restore them after File Explorer restarting
Clear-Variable -Name OpenedFolders -Force -ErrorAction Ignore
$Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke()
# Terminate the File Explorer process
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force
Stop-Process -Name explorer -Force
@ -4550,23 +4563,22 @@ public static bool MarkFileDelete (string sourcefile)
# Start the File Explorer process
Start-Process -FilePath explorer
# Restoring closed folders
foreach ($OpenedFolder in $OpenedFolders)
{
if (Test-Path -Path $OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $OpenedFolder
}
}
Remove-Item -Path $OneDriveFolder, $env:LOCALAPPDATA\OneDrive, $env:LOCALAPPDATA\Microsoft\OneDrive, "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" -Recurse -Force -ErrorAction Ignore
}
$Path = @(
$OneDriveFolder,
"$env:LOCALAPPDATA\OneDrive",
"$env:LOCALAPPDATA\Microsoft\OneDrive",
"$env:APPDATA\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk"
)
Remove-Item -Path $Path -Recurse -Force -ErrorAction Ignore
}
"Install"
{
$OneDrive = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -Force -ErrorAction Ignore
if (-not $OneDrive)
if ($OneDrive)
{
return
}
if (Test-Path -Path $env:SystemRoot\SysWOW64\OneDriveSetup.exe)
{
Write-Information -MessageData "" -InformationAction Continue
@ -4637,7 +4649,6 @@ public static bool MarkFileDelete (string sourcefile)
}
}
}
}
#endregion OneDrive
#region System

10
src/Sophia_Script_for_Windows_10/Sophia.ps1

@ -2,7 +2,7 @@
.SYNOPSIS
Default preset file for "Sophia Script for Windows 10"
Version: v5.15.0
Version: v5.15.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -70,7 +70,7 @@ param
Clear-Host
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.15.0 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.15.1 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force
@ -98,8 +98,8 @@ if ($Functions)
Invoke-Expression -Command $Function
}
# The "RefreshEnvironment" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {RefreshEnvironment; Errors}
# The "PostActions" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {PostActions; Errors}
exit
}
@ -1485,7 +1485,7 @@ UseStoreOpenWith -Hide
Перезапустить меню "Пуск"
Пожалуйста, не комментируйте данную функцию
#>
RefreshEnvironment
PostActions
<#
Errors output

8
src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1

@ -2,7 +2,7 @@
.SYNOPSIS
The TAB completion for functions and their arguments
Version: v5.5.0
Version: v5.5.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -44,13 +44,13 @@ function Sophia
Invoke-Expression -Command $Function
}
# The "RefreshEnvironment" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {RefreshEnvironment; Errors}
# The "PostActions" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {PostActions; Errors}
}
Clear-Host
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2019 v5.5.0 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2019 v5.5.1 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force

2
src/Sophia_Script_for_Windows_10_LTSC_2019/Manifest/Sophia.psd1

@ -1,6 +1,6 @@
@{
RootModule = '..\Module\Sophia.psm1'
ModuleVersion = '5.5.0'
ModuleVersion = '5.5.1'
GUID = 'a36a65ca-70f9-43df-856c-3048fc5e7f01'
Author = 'Dmitry "farag" Nefedov'
Copyright = '(c) 2014—2023 farag & Inestic. All rights reserved'

2
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -2,7 +2,7 @@
.SYNOPSIS
Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks
Version: v5.5.0
Version: v5.5.1
Date: 30.01.2023
Copyright (c) 20142023 farag

10
src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1

@ -2,7 +2,7 @@
.SYNOPSIS
Default preset file for "Sophia Script for Windows 10 LTSC 2019"
Version: v5.5.0
Version: v5.5.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -70,7 +70,7 @@ param
Clear-Host
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2019 v5.5.0 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2019 v5.5.1 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force
@ -98,8 +98,8 @@ if ($Functions)
Invoke-Expression -Command $Function
}
# The "RefreshEnvironment" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {RefreshEnvironment; Errors}
# The "PostActions" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {PostActions; Errors}
exit
}
@ -1137,7 +1137,7 @@ MultipleInvokeContext -Enable
Перезапустить меню "Пуск"
Пожалуйста, не комментируйте данную функцию
#>
RefreshEnvironment
PostActions
<#
Errors output

8
src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1

@ -2,7 +2,7 @@
.SYNOPSIS
The TAB completion for functions and their arguments
Version: v5.15.0
Version: v5.15.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -44,13 +44,13 @@ function Sophia
Invoke-Expression -Command $Function
}
# The "RefreshEnvironment" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {RefreshEnvironment; Errors}
# The "PostActions" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {PostActions; Errors}
}
Clear-Host
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2021 v5.15.0 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2021 v5.15.1 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force

2
src/Sophia_Script_for_Windows_10_LTSC_2021/Manifest/Sophia.psd1

@ -1,6 +1,6 @@
@{
RootModule = '..\Module\Sophia.psm1'
ModuleVersion = '5.15.0'
ModuleVersion = '5.15.1'
GUID = '109cc881-c42b-45af-a74a-550781989d6a'
Author = 'Dmitry "farag" Nefedov'
Copyright = '(c) 2014—2023 farag & Inestic. All rights reserved'

2
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -2,7 +2,7 @@
.SYNOPSIS
Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks
Version: v5.15.0
Version: v5.15.1
Date: 30.01.2023
Copyright (c) 20142023 farag

10
src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1

@ -2,7 +2,7 @@
.SYNOPSIS
Default preset file for "Sophia Script for Windows 10 LTSC 2021"
Version: v5.15.0
Version: v5.15.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -70,7 +70,7 @@ param
Clear-Host
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2021 v5.15.0 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2021 v5.15.1 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force
@ -98,8 +98,8 @@ if ($Functions)
Invoke-Expression -Command $Function
}
# The "RefreshEnvironment" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {RefreshEnvironment; Errors}
# The "PostActions" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {PostActions; Errors}
exit
}
@ -1284,7 +1284,7 @@ MultipleInvokeContext -Enable
Перезапустить меню "Пуск"
Пожалуйста, не комментируйте данную функцию
#>
RefreshEnvironment
PostActions
<#
Errors output

8
src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1

@ -2,7 +2,7 @@
.SYNOPSIS
The TAB completion for functions and their arguments
Version: v5.15.0
Version: v5.15.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -44,13 +44,13 @@ function Sophia
Invoke-Expression -Command $Function
}
# The "RefreshEnvironment" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {RefreshEnvironment; Errors}
# The "PostActions" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {PostActions; Errors}
}
Clear-Host
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.15.0 (PowerShell 7) | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.15.1 (PowerShell 7) | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force

2
src/Sophia_Script_for_Windows_10_PowerShell_7/Manifest/Sophia.psd1

@ -1,6 +1,6 @@
@{
RootModule = '..\Module\Sophia.psm1'
ModuleVersion = '5.15.0'
ModuleVersion = '5.15.1'
GUID = 'aa0b47a7-1770-4b5d-8c9f-cc6c505bcc7a'
Author = 'Dmitry "farag" Nefedov'
Copyright = '(c) 2014—2023 farag & Inestic. All rights reserved'

51
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -2,7 +2,7 @@
.SYNOPSIS
Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks
Version: v5.15.0
Version: v5.15.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -4440,8 +4440,25 @@ function OneDrive
[xml]$Uninstall = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -ErrorAction Ignore | ForEach-Object -Process {$_.SwidTagText}
[xml]$Uninstall = $Uninstall.SoftwareIdentity.InnerXml
[string]$UninstallString = $Uninstall.Meta.UninstallString
if ($UninstallString)
if (-not $UninstallString)
{
# OneDrive is not installed
return
}
# Check if script was launched from OneDrive folder and preset file has function to uninstall OneDrive
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and ($_.Text -eq "OneDrive -Uninstall") -or ($_.Text -match "Invoke-Expression")
}
# Check if user is logged into OneDrive account (Microsoft account)
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($PresetName -and $UserEmail)
{
# Exit if user accidentelly set function in preset to uninstall but he's logged into the app
return
}
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.OneDriveUninstalling -Verbose
@ -4461,7 +4478,7 @@ function OneDrive
# Get the OneDrive user folder path and remove it if it doesn't contain any user files
if (Test-Path -Path $env:OneDrive)
{
if ((Get-ChildItem -Path $env:OneDrive | Measure-Object).Count -eq 0)
if ((Get-ChildItem -Path $env:OneDrive -ErrorAction Ignore | Measure-Object).Count -eq 0)
{
Remove-Item -Path $env:OneDrive -Recurse -Force -ErrorAction Ignore
@ -4520,10 +4537,6 @@ public static bool MarkFileDelete (string sourcefile)
# Getting the OneDrive folder path
$OneDriveFolder = Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)
# Save all opened folders in order to restore them after File Explorer restarting
Clear-Variable -Name OpenedFolders -Force -ErrorAction Ignore
$Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke()
# Terminate the File Explorer process
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force
Stop-Process -Name explorer -Force
@ -4554,23 +4567,22 @@ public static bool MarkFileDelete (string sourcefile)
# Start the File Explorer process
Start-Process -FilePath explorer
# Restoring closed folders
foreach ($OpenedFolder in $OpenedFolders)
{
if (Test-Path -Path $OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $OpenedFolder
}
}
Remove-Item -Path $OneDriveFolder, $env:LOCALAPPDATA\OneDrive, $env:LOCALAPPDATA\Microsoft\OneDrive, "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" -Recurse -Force -ErrorAction Ignore
}
$Path = @(
$OneDriveFolder,
"$env:LOCALAPPDATA\OneDrive",
"$env:LOCALAPPDATA\Microsoft\OneDrive",
"$env:APPDATA\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk"
)
Remove-Item -Path $Path -Recurse -Force -ErrorAction Ignore
}
"Install"
{
$OneDrive = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -Force -ErrorAction Ignore
if (-not $OneDrive)
if ($OneDrive)
{
return
}
if (Test-Path -Path $env:SystemRoot\SysWOW64\OneDriveSetup.exe)
{
Write-Information -MessageData "" -InformationAction Continue
@ -4644,7 +4656,6 @@ public static bool MarkFileDelete (string sourcefile)
}
}
}
}
#endregion OneDrive
#region System

10
src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1

@ -2,7 +2,7 @@
.SYNOPSIS
Default preset file for "Sophia Script for Windows 10 (PowerShell 7)"
Version: v5.15.0
Version: v5.15.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -70,7 +70,7 @@ param
Clear-Host
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.15.0 (PowerShell 7) | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.15.1 (PowerShell 7) | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force
@ -107,8 +107,8 @@ if ($Functions)
Invoke-Expression -Command $Function
}
# The "RefreshEnvironment" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {RefreshEnvironment; Errors}
# The "PostActions" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {PostActions; Errors}
exit
}
@ -1494,7 +1494,7 @@ UseStoreOpenWith -Hide
Перезапустить меню "Пуск"
Пожалуйста, не комментируйте данную функцию
#>
RefreshEnvironment
PostActions
<#
Errors output

8
src/Sophia_Script_for_Windows_11/Functions.ps1

@ -2,7 +2,7 @@
.SYNOPSIS
The TAB completion for functions and their arguments
Version: v6.3.0
Version: v6.3.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -44,13 +44,13 @@ function Sophia
Invoke-Expression -Command $Function
}
# The "RefreshEnvironment" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {RefreshEnvironment; Errors}
# The "PostActions" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {PostActions; Errors}
}
Clear-Host
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.3.0 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.3.1 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force

2
src/Sophia_Script_for_Windows_11/Manifest/Sophia.psd1

@ -1,6 +1,6 @@
@{
RootModule = '..\Module\Sophia.psm1'
ModuleVersion = '6.3.0'
ModuleVersion = '6.3.1'
GUID = '109cc881-c42b-45af-a74a-550781989d6a'
Author = 'Dmitry "farag" Nefedov'
Copyright = '(c) 2014—2023 farag & Inestic. All rights reserved'

49
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -2,7 +2,7 @@
.SYNOPSIS
Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks
Version: v6.3.0
Version: v6.3.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -3916,8 +3916,25 @@ function OneDrive
"Uninstall"
{
[string]$UninstallString = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -ErrorAction Ignore | ForEach-Object -Process {$_.Meta.Attributes["UninstallString"]}
if ($UninstallString)
if (-not $UninstallString)
{
# OneDrive is not installed
return
}
# Check if script was launched from OneDrive folder and preset file has function to uninstall OneDrive
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and ($_.Text -eq "OneDrive -Uninstall") -or ($_.Text -match "Invoke-Expression")
}
# Check if user is logged into OneDrive account (Microsoft account)
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($PresetName -and $UserEmail)
{
# Exit if user accidentelly set function in preset to uninstall but he's logged into the app
return
}
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.OneDriveUninstalling -Verbose
@ -3996,10 +4013,6 @@ public static bool MarkFileDelete (string sourcefile)
# Getting the OneDrive folder path
$OneDriveFolder = Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)
# Save all opened folders in order to restore them after File Explorer restarting
Clear-Variable -Name OpenedFolders -Force -ErrorAction Ignore
$Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke()
# Terminate the File Explorer process
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force
Stop-Process -Name explorer -Force
@ -4030,23 +4043,22 @@ public static bool MarkFileDelete (string sourcefile)
# Start the File Explorer process
Start-Process -FilePath explorer
# Restoring closed folders
foreach ($OpenedFolder in $OpenedFolders)
{
if (Test-Path -Path $OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $OpenedFolder
}
}
Remove-Item -Path $OneDriveFolder, $env:LOCALAPPDATA\OneDrive, $env:LOCALAPPDATA\Microsoft\OneDrive, "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" -Recurse -Force -ErrorAction Ignore
}
$Path = @(
$OneDriveFolder,
"$env:LOCALAPPDATA\OneDrive",
"$env:LOCALAPPDATA\Microsoft\OneDrive",
"$env:APPDATA\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk"
)
Remove-Item -Path $Path -Recurse -Force -ErrorAction Ignore
}
"Install"
{
$OneDrive = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -Force -ErrorAction Ignore
if (-not $OneDrive)
if ($OneDrive)
{
return
}
if (Test-Path -Path $env:SystemRoot\SysWOW64\OneDriveSetup.exe)
{
Write-Information -MessageData "" -InformationAction Continue
@ -4117,7 +4129,6 @@ public static bool MarkFileDelete (string sourcefile)
}
}
}
}
#endregion OneDrive
#region System

10
src/Sophia_Script_for_Windows_11/Sophia.ps1

@ -2,7 +2,7 @@
.SYNOPSIS
Default preset file for "Sophia Script for Windows 11"
Version: v6.3.0
Version: v6.3.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -69,7 +69,7 @@ param
Clear-Host
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.3.0 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.3.1 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force
@ -97,8 +97,8 @@ if ($Functions)
Invoke-Expression -Command $Function
}
# The "RefreshEnvironment" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {RefreshEnvironment; Errors}
# The "PostActions" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {PostActions; Errors}
exit
}
@ -1401,7 +1401,7 @@ Windows10ContextMenu -Disable
Перезапустить меню "Пуск"
Пожалуйста, не комментируйте данную функцию
#>
RefreshEnvironment
PostActions
<#
Errors output

8
src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1

@ -2,7 +2,7 @@
.SYNOPSIS
The TAB completion for functions and their arguments
Version: v6.3.0
Version: v6.3.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -44,13 +44,13 @@ function Sophia
Invoke-Expression -Command $Function
}
# The "RefreshEnvironment" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {RefreshEnvironment; Errors}
# The "PostActions" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {PostActions; Errors}
}
Clear-Host
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.3.0 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.3.1 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force

2
src/Sophia_Script_for_Windows_11_PowerShell_7/Manifest/Sophia.psd1

@ -1,6 +1,6 @@
@{
RootModule = '..\Module\Sophia.psm1'
ModuleVersion = '6.3.0'
ModuleVersion = '6.3.1'
GUID = '109cc881-c42b-45af-a74a-550781989d6a'
Author = 'Dmitry "farag" Nefedov'
Copyright = '(c) 2014—2023 farag & Inestic. All rights reserved'

49
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -2,7 +2,7 @@
.SYNOPSIS
Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks
Version: v6.3.0
Version: v6.3.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -3920,8 +3920,25 @@ function OneDrive
[xml]$Uninstall = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -ErrorAction Ignore | ForEach-Object -Process {$_.SwidTagText}
[xml]$Uninstall = $Uninstall.SoftwareIdentity.InnerXml
[string]$UninstallString = $Uninstall.Meta.UninstallString
if ($UninstallString)
if (-not $UninstallString)
{
# OneDrive is not installed
return
}
# Check if script was launched from OneDrive folder and preset file has function to uninstall OneDrive
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and ($_.Text -eq "OneDrive -Uninstall") -or ($_.Text -match "Invoke-Expression")
}
# Check if user is logged into OneDrive account (Microsoft account)
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($PresetName -and $UserEmail)
{
# Exit if user accidentelly set function in preset to uninstall but he's logged into the app
return
}
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.OneDriveUninstalling -Verbose
@ -4000,10 +4017,6 @@ public static bool MarkFileDelete (string sourcefile)
# Getting the OneDrive folder path
$OneDriveFolder = Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)
# Save all opened folders in order to restore them after File Explorer restarting
Clear-Variable -Name OpenedFolders -Force -ErrorAction Ignore
$Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke()
# Terminate the File Explorer process
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force
Stop-Process -Name explorer -Force
@ -4034,23 +4047,22 @@ public static bool MarkFileDelete (string sourcefile)
# Start the File Explorer process
Start-Process -FilePath explorer
# Restoring closed folders
foreach ($OpenedFolder in $OpenedFolders)
{
if (Test-Path -Path $OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $OpenedFolder
}
}
Remove-Item -Path $OneDriveFolder, $env:LOCALAPPDATA\OneDrive, $env:LOCALAPPDATA\Microsoft\OneDrive, "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" -Recurse -Force -ErrorAction Ignore
}
$Path = @(
$OneDriveFolder,
"$env:LOCALAPPDATA\OneDrive",
"$env:LOCALAPPDATA\Microsoft\OneDrive",
"$env:APPDATA\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk"
)
Remove-Item -Path $Path -Recurse -Force -ErrorAction Ignore
}
"Install"
{
$OneDrive = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -Force -ErrorAction Ignore
if (-not $OneDrive)
if ($OneDrive)
{
return
}
if (Test-Path -Path $env:SystemRoot\SysWOW64\OneDriveSetup.exe)
{
Write-Information -MessageData "" -InformationAction Continue
@ -4124,7 +4136,6 @@ public static bool MarkFileDelete (string sourcefile)
}
}
}
}
#endregion OneDrive
#region System

10
src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

@ -2,7 +2,7 @@
.SYNOPSIS
Default preset file for "Sophia Script for Windows 11 (PowerShell 7)"
Version: v6.3.0
Version: v6.3.1
Date: 30.01.2023
Copyright (c) 20142023 farag
@ -69,7 +69,7 @@ param
Clear-Host
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.3.0 (PowerShell 7) | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.3.1 (PowerShell 7) | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows | $([char]0x00A9) farag & Inestic, 2014$([char]0x2013)2023"
Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force
@ -106,8 +106,8 @@ if ($Functions)
Invoke-Expression -Command $Function
}
# The "RefreshEnvironment" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {RefreshEnvironment; Errors}
# The "PostActions" and "Errors" functions will be executed at the end
Invoke-Command -ScriptBlock {PostActions; Errors}
exit
}
@ -1410,7 +1410,7 @@ Windows10ContextMenu -Disable
Перезапустить меню "Пуск"
Пожалуйста, не комментируйте данную функцию
#>
RefreshEnvironment
PostActions
<#
Errors output

Loading…
Cancel
Save