Skip to content

Commit b265675

Browse files
Removal of more winget user scope code
1 parent e023764 commit b265675

1 file changed

Lines changed: 0 additions & 56 deletions

File tree

functions/public/Invoke-WPFInstall.ps1

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -33,62 +33,6 @@ function Invoke-WPFInstall {
3333
try {
3434
$sync.ProcessRunning = $true
3535
if($packagesWinget.Count -gt 0 -and $packagesWinget -ne "0") {
36-
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
37-
Add-Type -assembly System.Windows.Forms
38-
$PrincipalContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('Machine')
39-
$user = $env:USERNAME
40-
41-
Get-LocalUser | Where-Object Enabled -eq $true | ForEach-Object {
42-
$validPassword = $false
43-
while (-not $validPassword) {
44-
try {
45-
$myPasswordIsBlank = $PrincipalContext.ValidateCredentials($user, $null)
46-
$validPassword = $true
47-
} catch {
48-
$form = New-Object System.Windows.Forms.Form
49-
$form.Text = "Set password for $user"
50-
$form.Size = New-Object System.Drawing.Size(500, 200)
51-
52-
$label = New-Object System.Windows.Forms.Label
53-
$label.Text = 'Admin mode install failed. Set a USER password for login and user-based installation.'
54-
$label.Size = New-Object System.Drawing.Size(480, 60)
55-
$label.Location = New-Object System.Drawing.Point(10, 10)
56-
$form.Controls.Add($label)
57-
58-
$passwordBox = New-Object System.Windows.Forms.TextBox
59-
$passwordBox.Size = New-Object System.Drawing.Size(380, 20)
60-
$passwordBox.UseSystemPasswordChar = $true
61-
$passwordBox.Location = New-Object System.Drawing.Point(10, 125)
62-
$form.Controls.Add($passwordBox)
63-
64-
$button = New-Object System.Windows.Forms.Button
65-
$button.Text = 'Submit'
66-
$button.Size = New-Object System.Drawing.Size(75, 23)
67-
$button.Location = New-Object System.Drawing.Point(400, 125)
68-
$button.Add_Click({
69-
$password = $passwordBox.Text | ConvertTo-SecureString -AsPlainText -Force
70-
if ($password) {
71-
try {
72-
Set-LocalUser -Name $user -Password $password
73-
$validPassword = $PrincipalContext.ValidateCredentials($user, $passwordBox.Text)
74-
if ($validPassword) {
75-
$form.Close()
76-
} else {
77-
[System.Windows.Forms.MessageBox]::Show('Invalid password! Please try again.')
78-
}
79-
} catch {
80-
[System.Windows.Forms.MessageBox]::Show('Error setting password!')
81-
}
82-
} else {
83-
[System.Windows.Forms.MessageBox]::Show('No password entered!')
84-
}
85-
})
86-
$form.Controls.Add($button)
87-
$form.ShowDialog() | Out-Null
88-
}
89-
}
90-
}
91-
9236
Show-WPFInstallAppBusy -text "Installing apps..."
9337
Install-WinUtilWinget
9438
Install-WinUtilProgramWinget -Action Install -Programs $packagesWinget

0 commit comments

Comments
 (0)