Update setupScriptInfo.ps1
This commit is contained in:
@@ -114,8 +114,17 @@ if ($UserSID -ne $null -and $UserHKUPath -ne $null) {
|
||||
|
||||
# Add entries to DisallowRun for cmd.exe and powershell.exe
|
||||
$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 ((Test-Path -Path $DisallowRunKeyPath) -and (Get-ItemProperty -Path "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "DisallowRun").DisallowRun -eq 1) {
|
||||
Write-Host "DisallowRun is already set to 1. Skipping the modification."
|
||||
} else {
|
||||
if (Test-Path -Path $DisallowRunKeyPath) {
|
||||
Set-ItemProperty -Path "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "DisallowRun" -Value 1
|
||||
} else {
|
||||
New-Item -Path $DisallowRunKeyPath -Force
|
||||
Set-ItemProperty -Path "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "DisallowRun" -Value 1
|
||||
}
|
||||
|
||||
$applications = @("cmd.exe", "powershell.exe", "powershell_ise.exe")
|
||||
foreach ($valueName in $applications) {
|
||||
$valueExists = $DisallowRunKeyPath.PSObject.Properties.Name -contains $valueName
|
||||
@@ -123,13 +132,6 @@ if ($UserSID -ne $null -and $UserHKUPath -ne $null) {
|
||||
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
|
||||
$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."
|
||||
|
||||
Reference in New Issue
Block a user