Browse Source

Added "/allusers" argument fpr OneDrive function

pull/450/head
Dmitry Nefedov 2 years ago
parent
commit
b1ea6cbc17
  1. 19
      src/Sophia_Script_for_Windows_10/Functions.ps1
  2. 109
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  3. 70
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  4. 69
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  5. 19
      src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1
  6. 115
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  7. 19
      src/Sophia_Script_for_Windows_11/Functions.ps1
  8. 118
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  9. 19
      src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1
  10. 122
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

19
src/Sophia_Script_for_Windows_10/Functions.ps1

@ -79,6 +79,25 @@ $Parameters = @{
{
$ParameterSets = (Get-Command -Name $Command).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}
# If a module command is OneDrive
if ($Command -eq "OneDrive")
{
(Get-Command -Name $Command).Name | Where-Object -FilterScript {$_ -like "*$wordToComplete*"}
# Get all command arguments, excluding defaults
foreach ($ParameterSet in $ParameterSets.Name)
{
# If an argument is AllUsers
if ($ParameterSet -eq "AllUsers")
{
# The "OneDrive -Install -AllUsers" construction
"OneDrive" + " " + "-Install" + " " + "-" + $ParameterSet | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
continue
}
}
# If a module command is PinToStart
if ($Command -eq "PinToStart")
{

109
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -4398,7 +4398,10 @@ function NavigationPaneExpand
Uninstall OneDrive
.PARAMETER Install
Install OneDrive 64-bit
Install OneDrive 64-bit depending which installer is triggered
.PARAMETER Install -AllUsers
Install OneDrive 64-bit for all users to %ProgramFiles% depending which installer is triggered
.EXAMPLE
OneDrive -Uninstall
@ -4406,6 +4409,9 @@ function NavigationPaneExpand
.EXAMPLE
OneDrive -Install
.EXAMPLE
OneDrive -Install -AllUsers
.NOTES
The OneDrive user folder won't be removed
@ -4428,7 +4434,14 @@ function OneDrive
ParameterSetName = "Install"
)]
[switch]
$Install
$Install,
[Parameter(
Mandatory = $true,
ParameterSetName = "Install"
)]
[switch]
$AllUsers
)
switch ($PSCmdlet.ParameterSetName)
@ -4573,12 +4586,20 @@ public static bool MarkFileDelete (string sourcefile)
return
}
if (Test-Path -Path $env:SystemRoot\SysWOW64\OneDriveSetup.exe)
if (Test-Path -Path $env:SystemRoot\System32\OneDriveSetup.exe)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.OneDriveInstalling -Verbose
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe
if ($AllUsers)
{
# Install OneDrive for all users
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
}
else
{
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -Wait
}
}
else
{
@ -4622,7 +4643,15 @@ public static bool MarkFileDelete (string sourcefile)
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\OneDriveSetup.exe" -Wait
if ($AllUsers)
{
# Install OneDrive for all users to %ProgramFiles%
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
}
else
{
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe
}
Remove-Item -Path "$DownloadsFolder\OneDriveSetup.exe" -Force
}
@ -6407,6 +6436,7 @@ function NetworkAdaptersSavePower
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {($_.Status -eq "Disconnected") -and $_.MacAddress}
)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Patient -Verbose
Start-Sleep -Seconds 2
}
@ -6939,7 +6969,6 @@ public static string GetString(uint strId)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose
Write-Information -MessageData "" -InformationAction Continue
# Store all drives letters to use them within ShowMenu function
$DriveLetters = @((Get-Disk | Where-Object -FilterScript {$_.BusType -ne "USB"} | Get-Partition | Get-Volume | Where-Object -FilterScript {$null -ne $_.DriveLetter}).DriveLetter | Sort-Object)
@ -6963,8 +6992,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DesktopLocalizedString
$No = $Localization.No
@ -6982,8 +7009,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6996,8 +7023,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DocumentsLocalizedString
$No = $Localization.No
@ -7015,8 +7040,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7029,8 +7054,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DownloadsLocalizedString
$No = $Localization.No
@ -7048,8 +7071,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7062,8 +7085,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $MusicLocalizedString
$No = $Localization.No
@ -7081,8 +7102,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7095,8 +7116,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $PicturesLocalizedString
$No = $Localization.No
@ -7114,8 +7133,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7128,8 +7147,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $VideosLocalizedString
$No = $Localization.No
@ -7147,8 +7164,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}
@ -7161,8 +7178,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DesktopLocalizedString
$Browse = $Localization.Browse
@ -7192,8 +7207,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7204,8 +7219,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DocumentsLocalizedString
$Browse = $Localization.Browse
@ -7235,8 +7248,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7247,8 +7260,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DownloadsLocalizedString
$Browse = $Localization.Browse
@ -7278,8 +7289,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7290,8 +7301,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $MusicLocalizedString
$Browse = $Localization.Browse
@ -7321,8 +7330,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7333,8 +7342,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $PicturesLocalizedString
$Browse = $Localization.Browse
@ -7364,8 +7371,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7376,8 +7383,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $VideosLocalizedString
$Browse = $Localization.Browse
@ -7407,8 +7412,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}
@ -7421,8 +7426,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DesktopLocalizedString
$Yes = $Localization.Yes
@ -7439,8 +7442,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7451,8 +7454,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DocumentsLocalizedString
$Yes = $Localization.Yes
@ -7469,8 +7470,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7481,8 +7482,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DownloadsLocalizedString
$Yes = $Localization.Yes
@ -7511,8 +7510,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $MusicLocalizedString
$Yes = $Localization.Yes
@ -7529,8 +7526,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7541,8 +7538,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $PicturesLocalizedString
$Yes = $Localization.Yes
@ -7559,8 +7554,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7589,8 +7584,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}

70
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -5105,6 +5105,7 @@ function NetworkAdaptersSavePower
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {($_.Status -eq "Disconnected") -and $_.MacAddress}
)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Patient -Verbose
Start-Sleep -Seconds 2
}
@ -5637,7 +5638,6 @@ public static string GetString(uint strId)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose
Write-Information -MessageData "" -InformationAction Continue
# Store all drives letters to use them within ShowMenu function
$DriveLetters = @((Get-Disk | Where-Object -FilterScript {$_.BusType -ne "USB"} | Get-Partition | Get-Volume | Where-Object -FilterScript {$null -ne $_.DriveLetter}).DriveLetter | Sort-Object)
@ -5661,8 +5661,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DesktopLocalizedString
$No = $Localization.No
@ -5680,8 +5678,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -5694,8 +5692,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DocumentsLocalizedString
$No = $Localization.No
@ -5713,8 +5709,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -5727,8 +5723,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DownloadsLocalizedString
$No = $Localization.No
@ -5746,8 +5740,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -5760,8 +5754,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $MusicLocalizedString
$No = $Localization.No
@ -5779,8 +5771,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -5793,8 +5785,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $PicturesLocalizedString
$No = $Localization.No
@ -5812,8 +5802,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -5826,8 +5816,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $VideosLocalizedString
$No = $Localization.No
@ -5845,8 +5833,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}
@ -5859,8 +5847,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DesktopLocalizedString
$Browse = $Localization.Browse
@ -5890,8 +5876,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -5902,8 +5888,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DocumentsLocalizedString
$Browse = $Localization.Browse
@ -5933,8 +5917,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -5945,8 +5929,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DownloadsLocalizedString
$Browse = $Localization.Browse
@ -5976,8 +5958,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -5988,8 +5970,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $MusicLocalizedString
$Browse = $Localization.Browse
@ -6019,8 +5999,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6031,8 +6011,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $PicturesLocalizedString
$Browse = $Localization.Browse
@ -6062,8 +6040,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6074,8 +6052,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $VideosLocalizedString
$Browse = $Localization.Browse
@ -6105,8 +6081,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}
@ -6119,8 +6095,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DesktopLocalizedString
$Yes = $Localization.Yes
@ -6137,8 +6111,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6149,8 +6123,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DocumentsLocalizedString
$Yes = $Localization.Yes
@ -6167,8 +6139,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6179,8 +6151,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DownloadsLocalizedString
$Yes = $Localization.Yes
@ -6209,8 +6179,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $MusicLocalizedString
$Yes = $Localization.Yes
@ -6227,8 +6195,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6239,8 +6207,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $PicturesLocalizedString
$Yes = $Localization.Yes
@ -6257,8 +6223,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6287,8 +6253,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}

69
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -6024,7 +6024,6 @@ public static string GetString(uint strId)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose
Write-Information -MessageData "" -InformationAction Continue
# Store all drives letters to use them within ShowMenu function
$DriveLetters = @((Get-Disk | Where-Object -FilterScript {$_.BusType -ne "USB"} | Get-Partition | Get-Volume | Where-Object -FilterScript {$null -ne $_.DriveLetter}).DriveLetter | Sort-Object)
@ -6048,8 +6047,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DesktopLocalizedString
$No = $Localization.No
@ -6067,8 +6064,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6081,8 +6078,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DocumentsLocalizedString
$No = $Localization.No
@ -6100,8 +6095,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6114,8 +6109,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DownloadsLocalizedString
$No = $Localization.No
@ -6133,8 +6126,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6147,8 +6140,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $MusicLocalizedString
$No = $Localization.No
@ -6166,8 +6157,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6180,8 +6171,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $PicturesLocalizedString
$No = $Localization.No
@ -6199,8 +6188,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6213,8 +6202,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $VideosLocalizedString
$No = $Localization.No
@ -6232,8 +6219,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}
@ -6246,8 +6233,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DesktopLocalizedString
$Browse = $Localization.Browse
@ -6277,8 +6262,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6289,8 +6274,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DocumentsLocalizedString
$Browse = $Localization.Browse
@ -6320,8 +6303,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6332,8 +6315,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DownloadsLocalizedString
$Browse = $Localization.Browse
@ -6363,8 +6344,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6375,8 +6356,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $MusicLocalizedString
$Browse = $Localization.Browse
@ -6406,8 +6385,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6418,8 +6397,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $PicturesLocalizedString
$Browse = $Localization.Browse
@ -6449,8 +6426,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6461,8 +6438,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $VideosLocalizedString
$Browse = $Localization.Browse
@ -6492,8 +6467,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}
@ -6506,8 +6481,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DesktopLocalizedString
$Yes = $Localization.Yes
@ -6524,8 +6497,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6536,8 +6509,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DocumentsLocalizedString
$Yes = $Localization.Yes
@ -6554,8 +6525,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6566,8 +6537,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DownloadsLocalizedString
$Yes = $Localization.Yes
@ -6596,8 +6565,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $MusicLocalizedString
$Yes = $Localization.Yes
@ -6614,8 +6581,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6626,8 +6593,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $PicturesLocalizedString
$Yes = $Localization.Yes
@ -6644,8 +6609,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6674,8 +6639,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}

19
src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1

@ -86,6 +86,25 @@ $Parameters = @{
{
$ParameterSets = (Get-Command -Name $Command).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}
# If a module command is OneDrive
if ($Command -eq "OneDrive")
{
(Get-Command -Name $Command).Name | Where-Object -FilterScript {$_ -like "*$wordToComplete*"}
# Get all command arguments, excluding defaults
foreach ($ParameterSet in $ParameterSets.Name)
{
# If an argument is AllUsers
if ($ParameterSet -eq "AllUsers")
{
# The "OneDrive -Install -AllUsers" construction
"OneDrive" + " " + "-Install" + " " + "-" + $ParameterSet | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
continue
}
}
# If a module command is PinToStart
if ($Command -eq "PinToStart")
{

115
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -4400,7 +4400,10 @@ function NavigationPaneExpand
Uninstall OneDrive
.PARAMETER Install
Install OneDrive 64-bit
Install OneDrive 64-bit depending which installer is triggered
.PARAMETER Install -AllUsers
Install OneDrive 64-bit for all users to %ProgramFiles% depending which installer is triggered
.EXAMPLE
OneDrive -Uninstall
@ -4408,6 +4411,9 @@ function NavigationPaneExpand
.EXAMPLE
OneDrive -Install
.EXAMPLE
OneDrive -Install -AllUsers
.NOTES
The OneDrive user folder won't be removed
@ -4430,16 +4436,21 @@ function OneDrive
ParameterSetName = "Install"
)]
[switch]
$Install
$Install,
[Parameter(
Mandatory = $true,
ParameterSetName = "Install"
)]
[switch]
$AllUsers
)
switch ($PSCmdlet.ParameterSetName)
{
"Uninstall"
{
[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
[string]$UninstallString = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -ErrorAction Ignore | ForEach-Object -Process {$_.Meta.Attributes["UninstallString"]}
if (-not $UninstallString)
{
# OneDrive is not installed
@ -4577,12 +4588,20 @@ public static bool MarkFileDelete (string sourcefile)
return
}
if (Test-Path -Path $env:SystemRoot\SysWOW64\OneDriveSetup.exe)
if (Test-Path -Path $env:SystemRoot\System32\OneDriveSetup.exe)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.OneDriveInstalling -Verbose
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe
if ($AllUsers)
{
# Install OneDrive for all users
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
}
else
{
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -Wait
}
}
else
{
@ -4592,7 +4611,6 @@ public static bool MarkFileDelete (string sourcefile)
$Parameters = @{
Uri = "https://www.google.com"
Method = "Head"
SslProtocol = "Tls12"
DisableKeepAlive = $true
UseBasicParsing = $true
}
@ -4609,7 +4627,6 @@ public static bool MarkFileDelete (string sourcefile)
# https://go.microsoft.com/fwlink/p/?LinkID=844652
$Parameters = @{
Uri = "https://g.live.com/1rewlive5skydrive/OneDriveProductionV2"
SslProtocol = "Tls12"
UseBasicParsing = $true
Verbose = $true
}
@ -4623,13 +4640,20 @@ public static bool MarkFileDelete (string sourcefile)
$Parameters = @{
Uri = $OneDriveURL
OutFile = "$DownloadsFolder\OneDriveSetup.exe"
SslProtocol = "Tls12"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\OneDriveSetup.exe" -Wait
if ($AllUsers)
{
# Install OneDrive for all users to %ProgramFiles%
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
}
else
{
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe
}
Remove-Item -Path "$DownloadsFolder\OneDriveSetup.exe" -Force
}
@ -6947,7 +6971,6 @@ public static string GetString(uint strId)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose
Write-Information -MessageData "" -InformationAction Continue
# Store all drives letters to use them within ShowMenu function
$DriveLetters = @((Get-Disk | Where-Object -FilterScript {$_.BusType -ne "USB"} | Get-Partition | Get-Volume | Where-Object -FilterScript {$null -ne $_.DriveLetter}).DriveLetter | Sort-Object)
@ -6971,8 +6994,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DesktopLocalizedString
$No = $Localization.No
@ -6990,8 +7011,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7004,8 +7025,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DocumentsLocalizedString
$No = $Localization.No
@ -7023,8 +7042,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7037,8 +7056,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DownloadsLocalizedString
$No = $Localization.No
@ -7056,8 +7073,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7070,8 +7087,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $MusicLocalizedString
$No = $Localization.No
@ -7089,8 +7104,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7103,8 +7118,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $PicturesLocalizedString
$No = $Localization.No
@ -7122,8 +7135,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7136,8 +7149,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $VideosLocalizedString
$No = $Localization.No
@ -7155,8 +7166,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}
@ -7169,8 +7180,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DesktopLocalizedString
$Browse = $Localization.Browse
@ -7200,8 +7209,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7212,8 +7221,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DocumentsLocalizedString
$Browse = $Localization.Browse
@ -7243,8 +7250,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7255,8 +7262,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DownloadsLocalizedString
$Browse = $Localization.Browse
@ -7286,8 +7291,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7298,8 +7303,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $MusicLocalizedString
$Browse = $Localization.Browse
@ -7329,8 +7332,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7341,8 +7344,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $PicturesLocalizedString
$Browse = $Localization.Browse
@ -7372,8 +7373,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7384,8 +7385,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $VideosLocalizedString
$Browse = $Localization.Browse
@ -7415,8 +7414,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}
@ -7429,8 +7428,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DesktopLocalizedString
$Yes = $Localization.Yes
@ -7447,8 +7444,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7459,8 +7456,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DocumentsLocalizedString
$Yes = $Localization.Yes
@ -7477,8 +7472,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7489,8 +7484,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DownloadsLocalizedString
$Yes = $Localization.Yes
@ -7519,8 +7512,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $MusicLocalizedString
$Yes = $Localization.Yes
@ -7537,8 +7528,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7549,8 +7540,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $PicturesLocalizedString
$Yes = $Localization.Yes
@ -7567,8 +7556,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7597,8 +7586,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}

19
src/Sophia_Script_for_Windows_11/Functions.ps1

@ -79,6 +79,25 @@ $Parameters = @{
{
$ParameterSets = (Get-Command -Name $Command).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}
# If a module command is OneDrive
if ($Command -eq "OneDrive")
{
(Get-Command -Name $Command).Name | Where-Object -FilterScript {$_ -like "*$wordToComplete*"}
# Get all command arguments, excluding defaults
foreach ($ParameterSet in $ParameterSets.Name)
{
# If an argument is AllUsers
if ($ParameterSet -eq "AllUsers")
{
# The "OneDrive -Install -AllUsers" construction
"OneDrive" + " " + "-Install" + " " + "-" + $ParameterSet | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
continue
}
}
# If a module command is UnpinTaskbarShortcuts
if ($Command -eq "UnpinTaskbarShortcuts")
{

118
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -3878,7 +3878,10 @@ function NavigationPaneExpand
Uninstall OneDrive
.PARAMETER Install
Install OneDrive 64-bit
Install OneDrive 64-bit depending which installer is triggered
.PARAMETER Install -AllUsers
Install OneDrive 64-bit for all users to %ProgramFiles% depending which installer is triggered
.EXAMPLE
OneDrive -Uninstall
@ -3886,6 +3889,9 @@ function NavigationPaneExpand
.EXAMPLE
OneDrive -Install
.EXAMPLE
OneDrive -Install -AllUsers
.NOTES
The OneDrive user folder won't be removed
@ -3908,7 +3914,14 @@ function OneDrive
ParameterSetName = "Install"
)]
[switch]
$Install
$Install,
[Parameter(
Mandatory = $true,
ParameterSetName = "Install"
)]
[switch]
$AllUsers
)
switch ($PSCmdlet.ParameterSetName)
@ -4001,7 +4014,12 @@ public static bool MarkFileDelete (string sourcefile)
}
Remove-ItemProperty -Path HKCU:\Environment -Name OneDrive, OneDriveConsumer -Force -ErrorAction Ignore
Remove-Item -Path HKCU:\Software\Microsoft\OneDrive, HKLM:\SOFTWARE\WOW6432Node\Microsoft\OneDrive, "$env:ProgramData\Microsoft OneDrive", $env:SystemDrive\OneDriveTemp -Recurse -Force -ErrorAction Ignore
$Path = @(
"HKCU:\Software\Microsoft\OneDrive",
"$env:ProgramData\Microsoft OneDrive",
"$env:SystemDrive\OneDriveTemp"
)
Remove-Item -Path $Path -Recurse -Force -ErrorAction Ignore
Unregister-ScheduledTask -TaskName *OneDrive* -Confirm:$false -ErrorAction Ignore
# Getting the OneDrive folder path
@ -4053,12 +4071,20 @@ public static bool MarkFileDelete (string sourcefile)
return
}
if (Test-Path -Path $env:SystemRoot\SysWOW64\OneDriveSetup.exe)
if (Test-Path -Path $env:SystemRoot\System32\OneDriveSetup.exe)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.OneDriveInstalling -Verbose
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe
if ($AllUsers)
{
# Install OneDrive for all users
Start-Process -FilePath $env:SystemRoot\System32\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
}
else
{
Start-Process -FilePath $env:SystemRoot\System32\OneDriveSetup.exe -Wait
}
}
else
{
@ -4102,7 +4128,15 @@ public static bool MarkFileDelete (string sourcefile)
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\OneDriveSetup.exe" -Wait
if ($AllUsers)
{
# Install OneDrive for all users to %ProgramFiles%
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
}
else
{
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe
}
Remove-Item -Path "$DownloadsFolder\OneDriveSetup.exe" -Force
}
@ -5884,6 +5918,7 @@ function NetworkAdaptersSavePower
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {($_.Status -eq "Disconnected") -and $_.MacAddress}
)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Patient -Verbose
Start-Sleep -Seconds 2
}
@ -6416,7 +6451,6 @@ public static string GetString(uint strId)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose
Write-Information -MessageData "" -InformationAction Continue
# Store all drives letters to use them within ShowMenu function
$DriveLetters = @((Get-Disk | Where-Object -FilterScript {$_.BusType -ne "USB"} | Get-Partition | Get-Volume | Where-Object -FilterScript {$null -ne $_.DriveLetter}).DriveLetter | Sort-Object)
@ -6440,8 +6474,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DesktopLocalizedString
$No = $Localization.No
@ -6459,8 +6491,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6473,8 +6505,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DocumentsLocalizedString
$No = $Localization.No
@ -6492,8 +6522,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6506,8 +6536,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DownloadsLocalizedString
$No = $Localization.No
@ -6525,8 +6553,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6539,8 +6567,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $MusicLocalizedString
$No = $Localization.No
@ -6558,8 +6584,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6572,8 +6598,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $PicturesLocalizedString
$No = $Localization.No
@ -6591,8 +6615,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6605,8 +6629,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $VideosLocalizedString
$No = $Localization.No
@ -6624,8 +6646,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}
@ -6638,8 +6660,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DesktopLocalizedString
$Browse = $Localization.Browse
@ -6669,8 +6689,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6681,8 +6701,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DocumentsLocalizedString
$Browse = $Localization.Browse
@ -6712,8 +6730,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6724,8 +6742,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DownloadsLocalizedString
$Browse = $Localization.Browse
@ -6755,8 +6771,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6767,8 +6783,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $MusicLocalizedString
$Browse = $Localization.Browse
@ -6798,8 +6812,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6810,8 +6824,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $PicturesLocalizedString
$Browse = $Localization.Browse
@ -6841,8 +6853,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6853,8 +6865,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $VideosLocalizedString
$Browse = $Localization.Browse
@ -6884,8 +6894,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}
@ -6898,8 +6908,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DesktopLocalizedString
$Yes = $Localization.Yes
@ -6916,8 +6924,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6928,8 +6936,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DocumentsLocalizedString
$Yes = $Localization.Yes
@ -6946,8 +6952,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6958,8 +6964,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DownloadsLocalizedString
$Yes = $Localization.Yes
@ -6988,8 +6992,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $MusicLocalizedString
$Yes = $Localization.Yes
@ -7006,8 +7008,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7018,8 +7020,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $PicturesLocalizedString
$Yes = $Localization.Yes
@ -7036,8 +7036,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7066,8 +7066,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}
@ -10567,6 +10567,7 @@ function HEVC
# Installing "HEVC Video Extensions from Device Manufacturer"
if ([System.Version]$HEVCPackageName -gt [System.Version](Get-AppxPackage -Name Microsoft.HEVCVideoExtension).Version)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Patient -Verbose
Write-Verbose -Message $Localization.HEVCDownloading -Verbose
@ -13391,6 +13392,7 @@ function UpdateLGPEPolicies
Write-Verbose -Message ([string]($_.FriendlyName, '|', $_.MediaType, '|', $_.BusType)) -Verbose
}
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Patient -Verbose
Write-Verbose -Message $Localization.GPOUpdate -Verbose
Write-Verbose -Message HKLM -Verbose

19
src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1

@ -86,6 +86,25 @@ $Parameters = @{
{
$ParameterSets = (Get-Command -Name $Command).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}
# If a module command is OneDrive
if ($Command -eq "OneDrive")
{
(Get-Command -Name $Command).Name | Where-Object -FilterScript {$_ -like "*$wordToComplete*"}
# Get all command arguments, excluding defaults
foreach ($ParameterSet in $ParameterSets.Name)
{
# If an argument is AllUsers
if ($ParameterSet -eq "AllUsers")
{
# The "OneDrive -Install -AllUsers" construction
"OneDrive" + " " + "-Install" + " " + "-" + $ParameterSet | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
continue
}
}
# If a module command is UnpinTaskbarShortcuts
if ($Command -eq "UnpinTaskbarShortcuts")
{

122
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -3880,7 +3880,10 @@ function NavigationPaneExpand
Uninstall OneDrive
.PARAMETER Install
Install OneDrive 64-bit
Install OneDrive 64-bit depending which installer is triggered
.PARAMETER Install -AllUsers
Install OneDrive 64-bit for all users to %ProgramFiles% depending which installer is triggered
.EXAMPLE
OneDrive -Uninstall
@ -3888,6 +3891,9 @@ function NavigationPaneExpand
.EXAMPLE
OneDrive -Install
.EXAMPLE
OneDrive -Install -AllUsers
.NOTES
The OneDrive user folder won't be removed
@ -3910,16 +3916,21 @@ function OneDrive
ParameterSetName = "Install"
)]
[switch]
$Install
$Install,
[Parameter(
Mandatory = $true,
ParameterSetName = "Install"
)]
[switch]
$AllUsers
)
switch ($PSCmdlet.ParameterSetName)
{
"Uninstall"
{
[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
[string]$UninstallString = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -ErrorAction Ignore | ForEach-Object -Process {$_.Meta.Attributes["UninstallString"]}
if (-not $UninstallString)
{
# OneDrive is not installed
@ -4005,7 +4016,12 @@ public static bool MarkFileDelete (string sourcefile)
}
Remove-ItemProperty -Path HKCU:\Environment -Name OneDrive, OneDriveConsumer -Force -ErrorAction Ignore
Remove-Item -Path HKCU:\Software\Microsoft\OneDrive, HKLM:\SOFTWARE\WOW6432Node\Microsoft\OneDrive, "$env:ProgramData\Microsoft OneDrive", $env:SystemDrive\OneDriveTemp -Recurse -Force -ErrorAction Ignore
$Path = @(
"HKCU:\Software\Microsoft\OneDrive",
"$env:ProgramData\Microsoft OneDrive",
"$env:SystemDrive\OneDriveTemp"
)
Remove-Item -Path $Path -Recurse -Force -ErrorAction Ignore
Unregister-ScheduledTask -TaskName *OneDrive* -Confirm:$false -ErrorAction Ignore
# Getting the OneDrive folder path
@ -4057,12 +4073,20 @@ public static bool MarkFileDelete (string sourcefile)
return
}
if (Test-Path -Path $env:SystemRoot\SysWOW64\OneDriveSetup.exe)
if (Test-Path -Path $env:SystemRoot\System32\OneDriveSetup.exe)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.OneDriveInstalling -Verbose
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe
if ($AllUsers)
{
# Install OneDrive for all users
Start-Process -FilePath $env:SystemRoot\System32\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
}
else
{
Start-Process -FilePath $env:SystemRoot\System32\OneDriveSetup.exe -Wait
}
}
else
{
@ -4072,7 +4096,6 @@ public static bool MarkFileDelete (string sourcefile)
$Parameters = @{
Uri = "https://www.google.com"
Method = "Head"
SslProtocol = "Tls13"
DisableKeepAlive = $true
UseBasicParsing = $true
}
@ -4089,7 +4112,6 @@ public static bool MarkFileDelete (string sourcefile)
# https://go.microsoft.com/fwlink/p/?LinkID=844652
$Parameters = @{
Uri = "https://g.live.com/1rewlive5skydrive/OneDriveProductionV2"
SslProtocol = "Tls13"
UseBasicParsing = $true
Verbose = $true
}
@ -4103,13 +4125,20 @@ public static bool MarkFileDelete (string sourcefile)
$Parameters = @{
Uri = $OneDriveURL
OutFile = "$DownloadsFolder\OneDriveSetup.exe"
SslProtocol = "Tls13"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\OneDriveSetup.exe" -Wait
if ($AllUsers)
{
# Install OneDrive for all users to %ProgramFiles%
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
}
else
{
Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe
}
Remove-Item -Path "$DownloadsFolder\OneDriveSetup.exe" -Force
}
@ -6424,7 +6453,6 @@ public static string GetString(uint strId)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose
Write-Information -MessageData "" -InformationAction Continue
# Store all drives letters to use them within ShowMenu function
$DriveLetters = @((Get-Disk | Where-Object -FilterScript {$_.BusType -ne "USB"} | Get-Partition | Get-Volume | Where-Object -FilterScript {$null -ne $_.DriveLetter}).DriveLetter | Sort-Object)
@ -6448,8 +6476,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DesktopLocalizedString
$No = $Localization.No
@ -6467,8 +6493,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6481,8 +6507,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DocumentsLocalizedString
$No = $Localization.No
@ -6500,8 +6524,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6514,8 +6538,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $DownloadsLocalizedString
$No = $Localization.No
@ -6533,8 +6555,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6547,8 +6569,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $MusicLocalizedString
$No = $Localization.No
@ -6566,8 +6586,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6580,8 +6600,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $PicturesLocalizedString
$No = $Localization.No
@ -6599,8 +6617,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6613,8 +6631,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderRequest -f $VideosLocalizedString
$No = $Localization.No
@ -6632,8 +6648,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}
@ -6646,8 +6662,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DesktopLocalizedString
$Browse = $Localization.Browse
@ -6677,8 +6691,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6689,8 +6703,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DocumentsLocalizedString
$Browse = $Localization.Browse
@ -6720,8 +6732,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6732,8 +6744,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $DownloadsLocalizedString
$Browse = $Localization.Browse
@ -6763,8 +6773,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6775,8 +6785,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $MusicLocalizedString
$Browse = $Localization.Browse
@ -6806,8 +6814,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6818,8 +6826,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $PicturesLocalizedString
$Browse = $Localization.Browse
@ -6849,8 +6855,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6861,8 +6867,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserFolderSelect -f $VideosLocalizedString
$Browse = $Localization.Browse
@ -6892,8 +6896,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}
@ -6906,8 +6910,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DesktopLocalizedString
$Yes = $Localization.Yes
@ -6924,8 +6926,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6936,8 +6938,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DocumentsLocalizedString
$Yes = $Localization.Yes
@ -6954,8 +6954,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -6966,8 +6966,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $DownloadsLocalizedString
$Yes = $Localization.Yes
@ -6996,8 +6994,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $MusicLocalizedString
$Yes = $Localization.Yes
@ -7014,8 +7010,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7026,8 +7022,6 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.FilesWontBeMoved
Write-Information -MessageData "" -InformationAction Continue
$Title = ""
$Message = $Localization.UserDefaultFolder -f $PicturesLocalizedString
$Yes = $Localization.Yes
@ -7044,8 +7038,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
@ -7074,8 +7068,8 @@ public static string GetString(uint strId)
}
"1"
{
Write-Verbose -Message $Localization.Skipped -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
}
}
}

Loading…
Cancel
Save