Update setupScriptInfo.ps1
This commit is contained in:
@@ -120,13 +120,11 @@ 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"
|
||||
$DisallowRunValueName = "DisallowRun"
|
||||
SetRegistry -regpath $DisallowRunKeyPath -regproperty $DisallowRunValueName
|
||||
|
||||
$DisallowRunPath = "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun"
|
||||
if (-not (Test-Path -Path "Registry::$DisallowRunPath" -PathType Container)) {
|
||||
New-Item -Path $DisallowRunPath -Force
|
||||
Set-ItemProperty -Path "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "DisallowRun" -Value 1
|
||||
}
|
||||
Set-ItemProperty -Path "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "DisallowRun" -Value 1
|
||||
$applications = @("cmd.exe", "powershell.exe", "powershell_ise.exe")
|
||||
Get-ItemProperty -Path $DisallowRunPath | ForEach-Object {
|
||||
Remove-ItemProperty -Path $DisallowRunPath -Name $_.PSObject.Properties.Name -ErrorAction SilentlyContinue
|
||||
@@ -134,7 +132,7 @@ if ($UserSID -ne $null -and $UserHKUPath -ne $null) {
|
||||
foreach ($valueName in $applications) {
|
||||
New-ItemProperty -Path $DisallowRunPath -Name $valueName -Value $valueName -PropertyType String
|
||||
}
|
||||
REG UNLOAD HKEY_USERS\$UserSID -ErrorAction SilentlyContinue
|
||||
REG UNLOAD HKEY_USERS\$UserSID
|
||||
} else {
|
||||
Write-Host "Unable to get the user's HKU registry."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user