mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-03 11:33:31 -05:00
Merge branch 'test-2024-03-30' into winget-install-fix
This commit is contained in:
@ -89,4 +89,13 @@ Function Get-WinUtilToggleStatus {
|
||||
return $true
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($ToggleSwitch -eq "WPFToggleTaskbarWidgets") {
|
||||
$TaskbarWidgets = (Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced").TaskBarDa
|
||||
if($TaskbarWidgets -eq 0) {
|
||||
return $false
|
||||
}
|
||||
else{
|
||||
return $true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ function Install-WinUtilWinget {
|
||||
Get-WinUtilWingetLatest
|
||||
Write-Host "Installing Winget w/ Prerequsites`r"
|
||||
Add-AppxProvisionedPackage -Online -PackagePath $ENV:TEMP\Microsoft.DesktopAppInstaller.msixbundle -DependencyPackagePath $ENV:TEMP\Microsoft.VCLibs.x64.Desktop.appx, $ENV:TEMP\Microsoft.UI.Xaml.x64.appx -LicensePath $ENV:TEMP\License1.xml
|
||||
Write-Host "Manually adding Winget Sources, from Winget CDN."
|
||||
Add-AppxPackage -Path https://cdn.winget.microsoft.com/cache/source.msix #Seems some installs of Winget don't add the repo source, this should makes sure that it's installed every time.
|
||||
Write-Host "Winget Installed" -ForegroundColor Green
|
||||
Write-Host "Enabling NuGet and Module..."
|
||||
Install-PackageProvider -Name NuGet -Force
|
||||
|
@ -54,38 +54,39 @@ function Remove-Features([switch] $dumpFeatures = $false, [switch] $keepDefender
|
||||
Remove-Features -keepDefender:$false
|
||||
|
||||
#>
|
||||
$appxlist = dism /English /image:$scratchDir /Get-Features | Select-String -Pattern "Feature Name : " -CaseSensitive -SimpleMatch
|
||||
$appxlist = $appxlist -split "Feature Name : " | Where-Object {$_}
|
||||
$featlist = (Get-WindowsOptionalFeature -Path $scratchDir).FeatureName
|
||||
if ($dumpFeatures)
|
||||
{
|
||||
$appxlist > allfeaturesdump.txt
|
||||
$featlist > allfeaturesdump.txt
|
||||
}
|
||||
|
||||
$appxlist = $appxlist | Where-Object {
|
||||
$featlist = $featlist | Where-Object {
|
||||
$_ -NotLike "*Printing*" -AND
|
||||
$_ -NotLike "*TelnetClient*" -AND
|
||||
$_ -NotLike "*PowerShell*" -AND
|
||||
$_ -NotLike "*NetFx*"
|
||||
$_ -NotLike "*NetFx*" -AND
|
||||
$_ -NotLike "*Media*" -AND
|
||||
$_ -NotLike "*NFS*"
|
||||
}
|
||||
|
||||
if ($keepDefender) { $appxlist = $appxlist | Where-Object { $_ -NotLike "*Defender*" }}
|
||||
if ($keepDefender) { $featlist = $featlist | Where-Object { $_ -NotLike "*Defender*" }}
|
||||
|
||||
foreach($feature in $appxlist)
|
||||
foreach($feature in $featlist)
|
||||
{
|
||||
$status = "Removing feature $feature"
|
||||
Write-Progress -Activity "Removing features" -Status $status -PercentComplete ($counter++/$appxlist.Count*100)
|
||||
Write-Progress -Activity "Removing features" -Status $status -PercentComplete ($counter++/$featlist.Count*100)
|
||||
Write-Debug "Removing feature $feature"
|
||||
# dism /image:$scratchDir /Disable-Feature /FeatureName:$feature /Remove /NoRestart > $null
|
||||
Disable-WindowsOptionalFeature -Path "$scratchDir" -FeatureName $feature -Remove -ErrorAction SilentlyContinue -NoRestart
|
||||
}
|
||||
Write-Progress -Activity "Removing features" -Status "Ready" -Completed
|
||||
Write-Host "You can re-enable the disabled features at any time, using either Windows Update or the SxS folder in <installation media>\Sources."
|
||||
}
|
||||
|
||||
function Remove-Packages
|
||||
{
|
||||
$appxlist = dism /English /Image:$scratchDir /Get-Packages | Select-String -Pattern "Package Identity : " -CaseSensitive -SimpleMatch
|
||||
$appxlist = $appxlist -split "Package Identity : " | Where-Object {$_}
|
||||
$pkglist = (Get-WindowsPackage -Path "$scratchDir").PackageName
|
||||
|
||||
$appxlist = $appxlist | Where-Object {
|
||||
$pkglist = $pkglist | Where-Object {
|
||||
$_ -NotLike "*ApplicationModel*" -AND
|
||||
$_ -NotLike "*indows-Client-LanguagePack*" -AND
|
||||
$_ -NotLike "*LanguageFeatures-Basic*" -AND
|
||||
@ -123,11 +124,18 @@ function Remove-Packages
|
||||
$_ -NotLike "*UI.XaML*"
|
||||
}
|
||||
|
||||
foreach ($appx in $appxlist)
|
||||
foreach ($pkg in $pkglist)
|
||||
{
|
||||
$status = "Removing $appx"
|
||||
Write-Progress -Activity "Removing Apps" -Status $status -PercentComplete ($counter++/$appxlist.Count*100)
|
||||
dism /English /image:$scratchDir /Remove-Package /PackageName:$appx /NoRestart
|
||||
try {
|
||||
$status = "Removing $pkg"
|
||||
Write-Progress -Activity "Removing Apps" -Status $status -PercentComplete ($counter++/$pkglist.Count*100)
|
||||
Remove-WindowsPackage -Path "$scratchDir" -PackageName $pkg -NoRestart -ErrorAction SilentlyContinue
|
||||
}
|
||||
catch {
|
||||
# This can happen if the package that is being removed is a permanent one, like FodMetadata
|
||||
Write-Host "Could not remove OS package $($pkg)"
|
||||
continue
|
||||
}
|
||||
}
|
||||
Write-Progress -Activity "Removing Apps" -Status "Ready" -Completed
|
||||
}
|
||||
@ -167,7 +175,7 @@ function Remove-ProvisionedPackages([switch] $keepSecurity = $false)
|
||||
{
|
||||
$status = "Removing Provisioned $($appx.PackageName)"
|
||||
Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100)
|
||||
dism /English /image:$scratchDir /Remove-ProvisionedAppxPackage /PackageName:$($appx.PackageName) /NoRestart
|
||||
Remove-AppxProvisionedPackage -Path $scratchDir -PackageName $appx.PackageName -ErrorAction SilentlyContinue
|
||||
}
|
||||
Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed
|
||||
}
|
||||
|
34
functions/private/Invoke-WinUtilTaskbarWidgets.ps1
Normal file
34
functions/private/Invoke-WinUtilTaskbarWidgets.ps1
Normal file
@ -0,0 +1,34 @@
|
||||
function Invoke-WinUtilTaskbarWidgets {
|
||||
<#
|
||||
|
||||
.SYNOPSIS
|
||||
Enable/Disable Taskbar Widgets
|
||||
|
||||
.PARAMETER Enabled
|
||||
Indicates whether to enable or disable Taskbar Widgets
|
||||
|
||||
#>
|
||||
Param($Enabled)
|
||||
Try{
|
||||
if ($Enabled -eq $false){
|
||||
Write-Host "Enabling Taskbar Widgets"
|
||||
$value = 1
|
||||
}
|
||||
else {
|
||||
Write-Host "Disabling Taskbar Widgets"
|
||||
$value = 0
|
||||
}
|
||||
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
|
||||
Set-ItemProperty -Path $Path -Name TaskbarDa -Value $value
|
||||
}
|
||||
Catch [System.Security.SecurityException] {
|
||||
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
|
||||
}
|
||||
Catch [System.Management.Automation.ItemNotFoundException] {
|
||||
Write-Warning $psitem.Exception.ErrorRecord
|
||||
}
|
||||
Catch{
|
||||
Write-Warning "Unable to set $Name due to unhandled exception"
|
||||
Write-Warning $psitem.Exception.StackTrace
|
||||
}
|
||||
}
|
@ -38,10 +38,12 @@ function Test-WinUtilPackageManager {
|
||||
|
||||
# Check if Winget's Version is too old.
|
||||
$wingetCurrentVersion = [System.Version]::Parse($wingetVersion.Trim('v'))
|
||||
$wingetBadVersion = [System.Version]::Parse("1.2.10691") # Windows 11 (22H2) comes with v1.2.10691, which is bugged.
|
||||
$wingetOutdated = $wingetCurrentVersion -le $wingetBadVersion
|
||||
# Grabs the latest release of Winget from the Github API for version check process.
|
||||
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/microsoft/Winget-cli/releases/latest" -Method Get -ErrorAction Stop
|
||||
$wingetLatestVersion = [System.Version]::Parse(($response.tag_name).Trim('v')) #Stores version number of latest release.
|
||||
$wingetOutdated = $wingetCurrentVersion -lt $wingetLatestVersion
|
||||
Write-Host "===========================================" -ForegroundColor Green
|
||||
Write-Host "-- Winget is installed ---" -ForegroundColor Green
|
||||
Write-Host "--- Winget is installed ---" -ForegroundColor Green
|
||||
Write-Host "===========================================" -ForegroundColor Green
|
||||
Write-Host "Version: $wingetVersionFull" -ForegroundColor White
|
||||
|
||||
@ -61,7 +63,7 @@ function Test-WinUtilPackageManager {
|
||||
}
|
||||
} else {
|
||||
Write-Host "===========================================" -ForegroundColor Red
|
||||
Write-Host "-- Winget is not installed ---" -ForegroundColor Red
|
||||
Write-Host "--- Winget is not installed ---" -ForegroundColor Red
|
||||
Write-Host "===========================================" -ForegroundColor Red
|
||||
$status = "not-installed"
|
||||
}
|
||||
@ -70,13 +72,13 @@ function Test-WinUtilPackageManager {
|
||||
if ($choco) {
|
||||
if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)) {
|
||||
Write-Host "===========================================" -ForegroundColor Green
|
||||
Write-Host "-- Chocolatey is installed ---" -ForegroundColor Green
|
||||
Write-Host "--- Chocolatey is installed ---" -ForegroundColor Green
|
||||
Write-Host "===========================================" -ForegroundColor Green
|
||||
Write-Host "Version: v$chocoVersion" -ForegroundColor White
|
||||
$status = "installed"
|
||||
} else {
|
||||
Write-Host "===========================================" -ForegroundColor Red
|
||||
Write-Host "-- Chocolatey is not installed ---" -ForegroundColor Red
|
||||
Write-Host "--- Chocolatey is not installed ---" -ForegroundColor Red
|
||||
Write-Host "===========================================" -ForegroundColor Red
|
||||
$status = "not-installed"
|
||||
}
|
||||
|
Reference in New Issue
Block a user