Buenas. Al final lo pude solucionar. Muchas gracias por la respuesta #el-brujo-
Como no encontre la solución para editar las directivas de grupo a traves del powershell. Lo hice editando el regedit.
He decidido hacer un script powerhsell que ter permite bloquear la aplicacion pasandole por parametro le nombre del ejecutable o nombres (separados por comas). Este script edita el editor de registros y deshabilitando el ejecutable gracias a DisallowRun.
script denyPrograms.ps1
#
# This script deny the programs specified
#
Param(
[String] $Programs
)
if(!$Programs){
Write-Host '[!]' -ForegroundColor Red -NoNewline;
Write-Host ' The script needs one argument.';
Write-Host ' denyPrograms.ps1 -Programs "<exe1>,<exe2>,<exe3>[,...]" ';
exit;
}
function prepareForDeny($path){
Get-Item -Path "$path" 2> $nul;
try{
New-Item -Path "$path\SOFTWARE\Microsoft\Windows\CurrentVersion" -Name "Policies";
}catch{
$null;
}
try{
New-Item -Path "$path\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies" -Name "explorer";
}catch{
$null;
}
try{
New-ItemProperty -Path "$path\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\explorer" -PropertyType DWord -Value 1 -Name "DisallowRun";
}catch{
$null;
}
try{
New-Item -Path "$path\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\explorer" -Name "DisallowRun";
}catch{
$null;
}
}
function denyPrograms($path){
if($Programs -eq "null"){
Clear-Item -Path "$path\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\explorer\DisallowRun";
continue;
}
Clear-Item -Path "$path\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\explorer\DisallowRun";
foreach($program in $Global:listPrograms){
New-ItemProperty -Path "$path\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\explorer\DisallowRun" -PropertyType String -Name $program -Value $program;
}
}
function currentUsers(){
$Global:currentUsers
= Get-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-21*" | ForEach-Object {$_.Name.Split
("\")[$_.Name.Split
("\").Length
-1]};
foreach($ssid in $Global:currentUsers){
$root = "HKU:\$ssid";
if(Get-Item -Path "$root" 2> $nul){
prepareForDeny $root;
$Global:listPrograms=$Programs -split ",";
denyPrograms $root;
}
}
}
function init(){
New-PSDrive HKU Registry HKEY_USERS > $null;
currentUsers;
}
init;
ejemplo de uso:
denyPrograms.ps1 -Programs "chrome.exe,msedge.exe"
o en segundo plano ejecutando un comando cmd:
powershell.exe & '/path/denyPrograms.ps1' -Programs "chrome.exe,msedge.exe"
Descripción: Bloquea el navegador Google Chrome y Microsoft Edge
Fuentes
https://es.wikihow.com/bloquear-una-aplicaci%C3%B3n-o-archivo-.exe-para-que-no-pueda-ejecutarse-en-Windowshttps://www.pdq.com/blog/modifying-the-registry-users-powershell/Espero que les sirva, y muchas gracias.