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