From ae0a8258e9403539c1f917e81316e7b89a624292 Mon Sep 17 00:00:00 2001 From: Lightemerald Date: Tue, 10 Oct 2023 08:38:08 +0000 Subject: [PATCH] Update setupScriptInfo.ps1 --- setupScriptInfo.ps1 | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/setupScriptInfo.ps1 b/setupScriptInfo.ps1 index c3df274..8d29085 100644 --- a/setupScriptInfo.ps1 +++ b/setupScriptInfo.ps1 @@ -98,31 +98,25 @@ if ($UserSID -ne $null -and $UserHKUPath -ne $null) { $DisallowRunKeyPath = "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun" if (Test-Path -Path $DisallowRunKeyPath) { Set-ItemProperty -Path "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "DisallowRun" -Value 1 - if ($DisallowRunKeyPath.PSObject.Properties.Name -contains "1") { - Set-ItemProperty -Path $DisallowRunKeyPath -Name "1" -Value "cmd.exe" -PropertyType String - } - else { - New-ItemProperty -Path $DisallowRunKeyPath -Name "1" -Value "cmd.exe" - } - if ($DisallowRunKeyPath.PSObject.Properties.Name -contains "2") { - New-ItemProperty -Path $DisallowRunKeyPath -Name "2" -Value "powershell.exe" -PropertyType String - } - else { - New-ItemProperty -Path $DisallowRunKeyPath -Name "2" -Value "powershell.exe" - } - if ($DisallowRunKeyPath.PSObject.Properties.Name -contains "3") { - New-ItemProperty -Path $DisallowRunKeyPath -Name "3" -Value "powershell_ise.exe" -PropertyType String - } - else { - New-ItemProperty -Path $DisallowRunKeyPath -Name "3" -Value "powershell_ise.exe" + $applications = @("cmd.exe", "powershell.exe", "powershell_ise.exe") + foreach ($valueName in $applications) { + $valueExists = $DisallowRunKeyPath.PSObject.Properties.Name -contains $valueName + if (!$valueExists) { + New-ItemProperty -Path $DisallowRunKeyPath -Name $valueName -Value $valueName -PropertyType String + } } } else { New-Item -Path $DisallowRunKeyPath -Force Set-ItemProperty -Path "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "DisallowRun" -Value 1 - New-ItemProperty -Path $DisallowRunKeyPath -Name "1" -Value "cmd.exe" -PropertyType String - New-ItemProperty -Path $DisallowRunKeyPath -Name "2" -Value "powershell.exe" -PropertyType String - New-ItemProperty -Path $DisallowRunKeyPath -Name "3" -Value "powershell_ise.exe" -PropertyType String + $applications = @("cmd.exe", "powershell.exe", "powershell_ise.exe") + foreach ($valueName in $applications) { + New-ItemProperty -Path $DisallowRunKeyPath -Name $valueName -Value $valueName -PropertyType String + } } } else { Write-Host "Unable to get the user's HKU registry." } + +Install-Module -Name PSWindowsUpdate -Force +Get-WindowsUpdate +Install-WindowsUpdate -AcceptAll -AutoReboot