Update setupScriptInfo.ps1

This commit is contained in:
2023-10-11 10:01:04 +00:00
parent 61d2de8bfc
commit eeb0fe5dba

View File

@@ -98,14 +98,14 @@ if ($UserSID -ne $null -and $UserHKUPath -ne $null) {
$DisallowRunValueName = "DisallowRun"
SetRegistry -regpath $DisallowRunKeyPath -regproperty $DisallowRunValueName
Write-Host (Get-ItemProperty -Path "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun")
$DisallowRunPath = "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun"
$applications = @("cmd.exe", "powershell.exe", "powershell_ise.exe")
Get-ItemProperty -Path $DisallowRunPath | ForEach-Object {
Remove-ItemProperty -Path $DisallowRunPath -Name $_.PSObject.Properties.Name
}
foreach ($valueName in $applications) {
$nameExists = $DisallowRunKeyPath.PSObject.Properties.Name -contains $valueName
$valueExists = $DisallowRunKeyPath.PSObject.Properties.Value -contains $valueName
if (!$valueExists && !$nameExists) {
New-ItemProperty -Path $DisallowRunKeyPath -Name $valueName -Value $valueName -PropertyType String
}
New-ItemProperty -Path $DisallowRunPath -Name $valueName -Value $valueName -PropertyType String
}
} else {
Write-Host "Unable to get the user's HKU registry."