From b2656755605b08eeb2097f2d24bcd2f8ca8ceca7 Mon Sep 17 00:00:00 2001 From: Chris Titus Tech Date: Mon, 17 Nov 2025 07:37:29 -0600 Subject: [PATCH] Removal of more winget user scope code --- functions/public/Invoke-WPFInstall.ps1 | 56 -------------------------- 1 file changed, 56 deletions(-) diff --git a/functions/public/Invoke-WPFInstall.ps1 b/functions/public/Invoke-WPFInstall.ps1 index 7085be7b..7bb0374e 100644 --- a/functions/public/Invoke-WPFInstall.ps1 +++ b/functions/public/Invoke-WPFInstall.ps1 @@ -33,62 +33,6 @@ function Invoke-WPFInstall { try { $sync.ProcessRunning = $true if($packagesWinget.Count -gt 0 -and $packagesWinget -ne "0") { - Add-Type -AssemblyName System.DirectoryServices.AccountManagement - Add-Type -assembly System.Windows.Forms - $PrincipalContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('Machine') - $user = $env:USERNAME - - Get-LocalUser | Where-Object Enabled -eq $true | ForEach-Object { - $validPassword = $false - while (-not $validPassword) { - try { - $myPasswordIsBlank = $PrincipalContext.ValidateCredentials($user, $null) - $validPassword = $true - } catch { - $form = New-Object System.Windows.Forms.Form - $form.Text = "Set password for $user" - $form.Size = New-Object System.Drawing.Size(500, 200) - - $label = New-Object System.Windows.Forms.Label - $label.Text = 'Admin mode install failed. Set a USER password for login and user-based installation.' - $label.Size = New-Object System.Drawing.Size(480, 60) - $label.Location = New-Object System.Drawing.Point(10, 10) - $form.Controls.Add($label) - - $passwordBox = New-Object System.Windows.Forms.TextBox - $passwordBox.Size = New-Object System.Drawing.Size(380, 20) - $passwordBox.UseSystemPasswordChar = $true - $passwordBox.Location = New-Object System.Drawing.Point(10, 125) - $form.Controls.Add($passwordBox) - - $button = New-Object System.Windows.Forms.Button - $button.Text = 'Submit' - $button.Size = New-Object System.Drawing.Size(75, 23) - $button.Location = New-Object System.Drawing.Point(400, 125) - $button.Add_Click({ - $password = $passwordBox.Text | ConvertTo-SecureString -AsPlainText -Force - if ($password) { - try { - Set-LocalUser -Name $user -Password $password - $validPassword = $PrincipalContext.ValidateCredentials($user, $passwordBox.Text) - if ($validPassword) { - $form.Close() - } else { - [System.Windows.Forms.MessageBox]::Show('Invalid password! Please try again.') - } - } catch { - [System.Windows.Forms.MessageBox]::Show('Error setting password!') - } - } else { - [System.Windows.Forms.MessageBox]::Show('No password entered!') - } - }) - $form.Controls.Add($button) - $form.ShowDialog() | Out-Null - } - } - } - Show-WPFInstallAppBusy -text "Installing apps..." Install-WinUtilWinget Install-WinUtilProgramWinget -Action Install -Programs $packagesWinget