{"id":353785,"date":"2024-09-11T13:43:58","date_gmt":"2024-09-11T13:43:58","guid":{"rendered":"https:\/\/www.ninjaone.com\/script-hub\/desactivar-el-inicio-de-sesion-automatico\/"},"modified":"2024-10-13T19:08:19","modified_gmt":"2024-10-13T19:08:19","slug":"desactivar-el-inicio-de-sesion-automatico","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/es\/script-hub\/desactivar-el-inicio-de-sesion-automatico\/","title":{"rendered":"C\u00f3mo desactivar el inicio de sesi\u00f3n autom\u00e1tico en Windows mediante un script de PowerShell para mejorar la seguridad"},"content":{"rendered":"<p>A medida que las ciberamenazas siguen evolucionando, los profesionales de TI deben mantenerse constantemente alerta para garantizar unos protocolos de seguridad s\u00f3lidos. Una de estas medidas es <strong>desactivar el inicio de sesi\u00f3n autom\u00e1tico en los sistemas Windows<\/strong>. Este post profundizar\u00e1 en la importancia de esta pr\u00e1ctica y proporcionar\u00e1 una gu\u00eda completa sobre c\u00f3mo conseguirlo mediante un script de PowerShell. Este script para desactivar el inicio de sesi\u00f3n autom\u00e1tico no s\u00f3lo lo desactiva, sino que tambi\u00e9n garantiza la presentaci\u00f3n de un banner de inicio de sesi\u00f3n, lo que <a href=\"https:\/\/www.ninjaone.com\/es\/blog\/lista-de-verificacion-de-seguridad-de-ti\/\" target=\"_blank\" rel=\"noopener\">mejora la seguridad general<\/a>.<\/p>\n<h2>Contexto<\/h2>\n<p>El inicio de sesi\u00f3n autom\u00e1tico, aunque c\u00f3modo para los usuarios, plantea importantes riesgos de seguridad, sobre todo en entornos en los que se puede acceder a datos sensibles. Desactivar esta funci\u00f3n obliga a los usuarios a autenticarse cada vez que inician sesi\u00f3n, lo que proporciona una capa adicional de seguridad. Para los profesionales de TI y los <a href=\"https:\/\/www.ninjaone.com\/es\/que-es-un-msp\" target=\"_blank\" rel=\"noopener\">proveedores de servicios gestionados (MSP)<\/a>, la automatizaci\u00f3n de este proceso mediante scripts puede ahorrar tiempo y garantizar la coherencia entre varios sistemas.<\/p>\n<h2>El script para desactivar el inicio de sesi\u00f3n autom\u00e1tico<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Disables the automatic login feature and ensures that a dialog box is presented each time a user signs in.\r\n.DESCRIPTION\r\n    Disables the automatic login feature and ensures that a dialog box is presented each time a user signs in.\r\n.EXAMPLE\r\n    -Title \"A Title\" -Message \"A Message\"\r\n    \r\n    Retrieving existing security policy...\r\n                                                                           \r\n    The task has completed successfully.\r\n    See log %windir%\\security\\logs\\scesrv.log for detail info.\r\n    Modifying policy to include the login banner.\r\n    Applying updated policy...\r\n    Completed 5 percent (0\/18) \tProcess Security Policy area        \r\n    Completed 22 percent (3\/18) \tProcess Security Policy area        \r\n    Completed 44 percent (7\/18) \tProcess Security Policy area        \r\n    Completed 61 percent (10\/18) \tProcess Security Policy area        \r\n    Completed 77 percent (13\/18) \tProcess Security Policy area        \r\n    Completed 100 percent (18\/18) \tProcess Security Policy area        \r\n                                                                            \r\n    The task has completed successfully.\r\n    See log %windir%\\security\\logs\\scesrv.log for detail info.\r\n\r\n\r\nPARAMETER: -Title \"ReplaceMeWithYourDesiredTitle\"\r\n    Specify the title of the dialog box to be used in the logon banner.\r\n\r\nPARAMETER: -Message \"ReplaceMeWithYourDesiredMessage\"\r\n    Specify the main text body to be used in the logon banner. \r\n\r\nPARAMETER: -MicrosoftDefaults\r\n    Reverts all the modified settings to their Microsoft default value.\r\n\r\nPARAMETER: -ForceRestart\r\n    Schedules a restart for 60 seconds from now so that the login banner may take immediate effect.\r\n\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows Server 2016\r\n    Release Notes: Initial Release\r\nBy using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n    Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nparam (\r\n    [Parameter()]\r\n    [String]$Title,\r\n    [Parameter()]\r\n    [String]$Message,\r\n    [Parameter()]\r\n    [Switch]$MicrosoftDefaults = [System.Convert]::ToBoolean($env:revertToMicrosoftDefaults),\r\n    [Parameter()]\r\n    [Switch]$ForceRestart = [System.Convert]::ToBoolean($env:forceRestart)\r\n)\r\n\r\nbegin {\r\n    if ($env:logonBannerTitle -and $env:logonBannerTitle -notlike \"null\") { $Title = $env:logonBannerTitle }\r\n    if ($env:logonBannerText -and $env:logonBannerText -notlike \"null\") { $Message = $env:logonBannerText }\r\n\r\n    # Check if a title is provided. If it exists, trim any leading or trailing whitespace.\r\n    if ($Title) {\r\n        $Title = $Title.Trim()\r\n    }\r\n\r\n    # If no title is provided and Microsoft defaults are not being used, output an error and exit the script.\r\n    if (!$Title -and !$MicrosoftDefaults) {\r\n        Write-Host \"[Error] Missing title for the login banner.\"\r\n        exit 1\r\n    }\r\n\r\n    # Check if a message is provided. If it exists, trim any leading or trailing whitespace.\r\n    if ($Message) {\r\n        $Message = $Message.Trim()\r\n    }\r\n\r\n    # If no message is provided and Microsoft defaults are not being used, output an error and exit the script.\r\n    if (!$Message -and !$MicrosoftDefaults) {\r\n        Write-Host \"[Error] Missing message for the login banner.\"\r\n        exit 1\r\n    }\r\n\r\n    # If Microsoft defaults are specified to be used but either a title or message is also provided, error out due to the title and message not being present by default.\r\n    if ($MicrosoftDefaults -and ($Title -or $Message)) {\r\n        Write-Host \"[Error] A login banner is not present by default. If you use the 'Revert To Microsoft Defaults' checkmark, leave the 'Login Banner Title' and the 'Login Banner Text' empty.\"\r\n        exit 1\r\n    }\r\n\r\n    function Test-IsDomainJoined {\r\n        if ($PSVersionTable.PSVersion.Major -lt 5) {\r\n            return $(Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain\r\n        }\r\n        else {\r\n            return $(Get-CimInstance -Class Win32_ComputerSystem).PartOfDomain\r\n        }\r\n    }\r\n\r\n    function Set-RegKey {\r\n        param (\r\n            $Path,\r\n            $Name,\r\n            $Value,\r\n            [ValidateSet(\"DWord\", \"QWord\", \"String\", \"ExpandedString\", \"Binary\", \"MultiString\", \"Unknown\")]\r\n            $PropertyType = \"DWord\"\r\n        )\r\n\r\n        # Check if the specified path exists, if not, create it.\r\n        if (-not $(Test-Path -Path $Path)) {\r\n            New-Item -Path $Path -Force | Out-Null\r\n        }\r\n\r\n        # Check if the property already exists at the path.\r\n        if ((Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue)) {\r\n\r\n            # Retrieve the current value of the registry key.\r\n            $CurrentValue = (Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue).$Name\r\n            try {\r\n                # Attempt to update the property's value.\r\n                Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false -ErrorAction Stop | Out-Null\r\n            }\r\n            catch {\r\n                # If an error occurs during the update, print an error message and exit.\r\n                Write-Host \"[Error] Unable to Set registry key for $Name please see below error!\"\r\n                Write-Host \"[Error] $($_.Message)\"\r\n                exit 1\r\n            }\r\n            # Print a confirmation of the change.\r\n            Write-Host \"$Path\\$Name changed from $CurrentValue to $($(Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue).$Name)\"\r\n        }\r\n        else {\r\n            try {\r\n                # If the property does not exist, create it with the specified value and type.\r\n                New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force -Confirm:$false -ErrorAction Stop | Out-Null\r\n            }\r\n            catch {\r\n                # If an error occurs during creation, print an error message and exit.\r\n                Write-Host \"[Error] Unable to Set registry key for $Name please see below error!\"\r\n                Write-Host \"[Error] $($_.Exception.Message)\"\r\n                exit 1\r\n            }\r\n\r\n            # Print a confirmation of the change.\r\n            Write-Host \"Set $Path\\$Name to $($(Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue).$Name)\"\r\n        }\r\n    }\r\n    function Test-IsElevated {\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n        $p = New-Object System.Security.Principal.WindowsPrincipal($id)\r\n        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)\r\n    }\r\n\r\n    if (!$ExitCode) {\r\n        $ExitCode = 0\r\n    }\r\n}\r\nprocess {\r\n    # Check if the current user session is elevated with administrator privileges. If not, display an error message and exit the script.\r\n    if (!(Test-IsElevated)) {\r\n        Write-Host -Object \"[Error] Access Denied. Please run with Administrator privileges.\"\r\n        exit 1\r\n    }\r\n\r\n    # Retrieve the AutoAdminLogon and DefaultPassword registry values to check for automatic login settings and stored passwords.\r\n    $AutoLogin = Get-ItemProperty -Path \"Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\" -Name \"AutoAdminLogon\" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty \"AutoAdminLogon\" -ErrorAction SilentlyContinue\r\n    $DefaultPassword = Get-ItemProperty -Path \"Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\" -Name \"DefaultPassword\" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty \"DefaultPassword\" -ErrorAction SilentlyContinue\r\n    $PasswordLessSetting = Get-ItemProperty -Path \"Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\PasswordLess\\Device\" -Name \"DevicePasswordLessBuildVersion\" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty \"DevicePasswordLessBuildVersion\" -ErrorAction SilentlyContinue\r\n\r\n    # Alert if a password is stored in the registry, which might be insecure if in plain text.\r\n    if ($DefaultPassword) {\r\n        Write-Host \"[Alert] A Password is stored in HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\DefaultPassword. This password is likely in plain text.\"\r\n    }\r\n\r\n    # Check if the device is part of a domain, and if so, recommend using group policy for login banner settings.\r\n    if (Test-IsDomainJoined) {\r\n        Write-Host \"[Error] This device is domain joined. Login Banner modifications should be setup using group policy.\"\r\n        Write-Host \"[Info] Group Policy Location: Computer Configuration &gt; Windows Settings &gt; Security Settings &gt; Local Policies &gt; Security Options &gt; Interactive logon:(...)\"\r\n        Write-Host \"[Info] https:\/\/learn.microsoft.com\/en-us\/previous-versions\/windows\/it-pro\/windows-10\/security\/threat-protection\/security-policy-settings\/interactive-logon-message-text-for-users-attempting-to-log-on\"\r\n        exit 1\r\n    }\r\n\r\n    # Turn off automatic login if it is enabled.\r\n    if ($AutoLogin -ne 0) {\r\n        Set-RegKey -Path \"Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\" -Name \"AutoAdminLogon\" -Value 0\r\n    }\r\n\r\n    # Disable automatic login if it is enabled\r\n    if ($PasswordLessSetting -eq 0) {\r\n        Set-RegKey -Path \"Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\PasswordLess\\Device\" -Name \"DevicePasswordLessBuildVersion\" -Value 2\r\n    }\r\n\r\n    # Announce the start of the security policy retrieval process.\r\n    Write-Host \"Retrieving existing security policy...\"\r\n\r\n    # Export the current security policy and record the output to a temporary file.\r\n    $SecurityPolicyPath = \"$env:TEMP\\enable-loginbanner.cfg\"\r\n    $ExportPolicy = Start-Process SecEdit.exe -ArgumentList \"\/export \/cfg $SecurityPolicyPath\" -RedirectStandardOutput \"$env:TEMP\\enable-loginbanner.txt\" -NoNewWindow -Wait -PassThru\r\n    $ExportPolicyOutput = Get-Content -Path \"$env:TEMP\\enable-loginbanner.txt\"\r\n\r\n    # Display the output of the policy export and clean up the temporary file.\r\n    if ($ExportPolicyOutput) {\r\n        $ExportPolicyOutput | Write-Host\r\n        Remove-Item \"$env:TEMP\\enable-loginbanner.txt\"\r\n    }\r\n\r\n    # Check the exit code of the export process and display an error message if the export failed.\r\n    if ($ExportPolicy.ExitCode -ne 0) {\r\n        Write-Host -Object \"Exit Code: $($ExportPolicy.ExitCode)\"\r\n        Write-Host -Object \"[Error] Unable to edit security policy.\"\r\n        exit 1\r\n    }\r\n    \r\n    # Check if Microsoft default settings are specified to modify the login banner.\r\n    if ($MicrosoftDefaults) {\r\n        Write-Host \"Removing login banner from security policy...\"\r\n\r\n        # Initialize a new list to store modified security policy settings.\r\n        $NewSecPolicy = New-Object System.Collections.Generic.List[string]\r\n\r\n        # Read the current security policy and process each line.\r\n        Get-Content $SecurityPolicyPath | ForEach-Object {\r\n\r\n            # If the line contains settings for LegalNoticeCaption or LegalNoticeText, reset these values.\r\n            if ($_ -match \"LegalNoticeCaption\" -or $_ -match \"LegalNoticeText\") {\r\n                $NewSecPolicy.Add(($_ -replace \",.*\", \",\"))\r\n            }\r\n            else {\r\n                $NewSecPolicy.Add($_)\r\n            }\r\n        }\r\n\r\n        # Write the modified security policy back to the configuration file.\r\n        $NewSecPolicy | Out-File $SecurityPolicyPath\r\n\r\n        Write-Host \"Applying updated policy...\"\r\n        # Apply the modified security policy using SecEdit.exe.\r\n        $UpdateSecurityPolicy = Start-Process SecEdit.exe -ArgumentList \"\/configure \/db c:\\windows\\security\\local.sdb \/cfg $SecurityPolicyPath\" -RedirectStandardOutput \"$env:TEMP\\enable-loginbanner.txt\" -Wait -NoNewWindow -PassThru\r\n    \r\n        # Capture the output from the policy update and display it.\r\n        $UpdatePolicyOutput = Get-Content -Path \"$env:TEMP\\enable-loginbanner.txt\"\r\n        if ($UpdatePolicyOutput) {\r\n            $UpdatePolicyOutput | Write-Host\r\n            Remove-Item \"$env:TEMP\\enable-loginbanner.txt\"\r\n        }\r\n    \r\n\r\n        # Check the exit code of the policy update process and handle errors.\r\n        if ($UpdateSecurityPolicy.ExitCode -ne 0) {\r\n            Write-Host -Object \"Exit Code: $($UpdateSecurityPolicy.ExitCode)\"\r\n            Write-Host -Object \"[Error] Unable to update security policy.\"\r\n            exit 1\r\n        }\r\n        else {\r\n\r\n            if ($ForceRestart) {\r\n                Write-Warning -Message \"Scheduling system restart for 60 seconds from now. $((Get-Date).AddMinutes(60))\"\r\n                Start-Process shutdown.exe -ArgumentList \"\/r \/t 60\" -Wait -NoNewWindow\r\n            }\r\n            else {\r\n                Write-Warning -Message \"A restart may be required for the login banner to be removed. Please restart at your earliest convenience.\"\r\n            }\r\n            \r\n            exit $ExitCode\r\n        }\r\n    }\r\n\r\n    # Begin modification to include the login banner in the security policy.\r\n    Write-Host \"Modifying policy to include the login banner.\"\r\n\r\n    # Check if the current policy already includes a title for the login banner.\r\n    if (Get-Content $SecurityPolicyPath | Where-Object { $_ -like \"*LegalNoticeCaption*\" }) {\r\n        # Replace the existing title with a new one, maintaining other parts of the line.\r\n        $Caption = (Get-Content $SecurityPolicyPath | Where-Object { $_ -like \"*LegalNoticeCaption*\" }) -replace ',.*', \",`\"$Title`\"\"\r\n        (Get-Content $SecurityPolicyPath) -replace \".*LegalNoticeCaption.*\", \"$Caption\" | Out-File $SecurityPolicyPath\r\n    }\r\n    else {\r\n        # If no title is present, create a new list for the modified policy settings.\r\n        $NewSecPolicy = New-Object System.Collections.Generic.List[string]\r\n        # Define the new title setting with the specified title\r\n        $Caption = \"MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\LegalNoticeCaption=1,`\"$Title`\"\"\r\n\r\n        # Read the current policy and add the new title setting where appropriate.\r\n        Get-Content $SecurityPolicyPath | ForEach-Object {\r\n            if ($_ -match \"\\[Registry Values\\]\") {\r\n                $NewSecPolicy.Add($_)\r\n                $NewSecPolicy.Add($Caption)\r\n            }\r\n            else {\r\n                $NewSecPolicy.Add($_)\r\n            }\r\n        }\r\n\r\n        # Write the modified settings back to the configuration file.\r\n        $NewSecPolicy | Out-File $SecurityPolicyPath\r\n    }\r\n\r\n    # Check if the security policy file shows that the login banner text has already been set.\r\n    if (Get-Content $SecurityPolicyPath | Where-Object { $_ -like \"*LegalNoticeText*\" }) {\r\n        # If the setting is found, modify its existing entry by replacing the existing text after the comma\r\n        # with a formatted version of $Message. Commas in $Message are replaced with '\",\"', and new lines are replaced with commas.\r\n        $Text = (Get-Content $SecurityPolicyPath | Where-Object { $_ -like \"*LegalNoticeText*\" }) -replace ',.*', \",$($Message -replace ',','\",\"' -replace '\\n',',')\"\r\n        \r\n        # Replace the entire line that contains \"LegalNoticeText\" with the new formatted text, and overwrite the file.\r\n        (Get-Content $SecurityPolicyPath) -replace \".*LegalNoticeText.*\", \"$Text\" | Out-File $SecurityPolicyPath\r\n    }\r\n    else {\r\n        # If the setting is not found in the file, initialize a new list to store all lines for the updated policy.\r\n        $NewSecPolicy = New-Object System.Collections.Generic.List[string]\r\n\r\n        # Create a new line for \"LegalNoticeText\" with the provided $Message formatted similarly to the replacement process above.\r\n        $Text = \"MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\LegalNoticeText=7,$($Message -replace ',','\",\"' -replace '\\n',',')\"\r\n\r\n        # Read each line of the security policy. If the line matches \"[Registry Values]\", it indicates the start of registry settings.\r\n        Get-Content $SecurityPolicyPath | ForEach-Object {\r\n            if ($_ -match \"\\[Registry Values\\]\") {\r\n                # Add the current line and immediately follow it with the new \"LegalNoticeText\" setting.\r\n                $NewSecPolicy.Add($_)\r\n                $NewSecPolicy.Add($Text)\r\n            }\r\n            else {\r\n                # Add other lines without modification.\r\n                $NewSecPolicy.Add($_)\r\n            }\r\n        }\r\n\r\n        # Write the updated list back to the security policy file, thus including the new \"LegalNoticeText\".\r\n        $NewSecPolicy | Out-File $SecurityPolicyPath\r\n    }\r\n\r\n    # Display a message indicating that the updated security policy is being applied.\r\n    Write-Host \"Applying updated policy...\"\r\n    $UpdateSecurityPolicy = Start-Process SecEdit.exe -ArgumentList \"\/configure \/db c:\\windows\\security\\local.sdb \/cfg $SecurityPolicyPath \/areas securitypolicy\" -RedirectStandardOutput \"$env:TEMP\\enable-loginbanner.txt\" -Wait -NoNewWindow -PassThru\r\n    \r\n    $UpdatePolicyOutput = Get-Content -Path \"$env:TEMP\\enable-loginbanner.txt\"\r\n    # If there is any output from the SecEdit process, display it in the console.\r\n    if ($UpdatePolicyOutput) {\r\n        $UpdatePolicyOutput | Write-Host\r\n        Remove-Item \"$env:TEMP\\enable-loginbanner.txt\"\r\n    }\r\n    \r\n\r\n    # Check if the SecEdit process completed successfully by examining the exit code.\r\n    if ($UpdateSecurityPolicy.ExitCode -ne 0) {\r\n        Write-Host -Object \"Exit Code: $($UpdateSecurityPolicy.ExitCode)\"\r\n        Write-Host -Object \"[Error] Unable to update security policy.\"\r\n        exit 1\r\n    }\r\n\r\n    if ($ForceRestart) {\r\n        Write-Warning -Message \"Scheduling system restart for 60 seconds from now. $((Get-Date).AddMinutes(60))\"\r\n        Start-Process shutdown.exe -ArgumentList \"\/r \/t 60\" -Wait -NoNewWindow\r\n    }\r\n    else {\r\n        Write-Warning -Message \"A restart may be required for the login banner to take effect. Please restart at your earliest convenience.\"\r\n    }\r\n    \r\n    exit $ExitCode\r\n}\r\nend {\r\n    \r\n    \r\n    \r\n}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"blog-cta-new blog-cta-style-1\"><div class=\"cta-left\"><h2><\/h2><p><\/p><\/div><div class=\"cta-right\"><a class=\"button\" href=\"\"><\/a><\/div><\/div>\n<h2>An\u00e1lisis detallado<\/h2>\n<p>Este script de PowerShell est\u00e1 dise\u00f1ado para desactivar el inicio de sesi\u00f3n autom\u00e1tico y garantizar que se presente un cuadro de di\u00e1logo cada vez que un usuario inicie sesi\u00f3n. Aqu\u00ed tienes una explicaci\u00f3n paso a paso de c\u00f3mo funciona:<\/p>\n<ol>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Par\u00e1metros y comprobaciones iniciales:<\/strong> el script para desactivar el inicio de sesi\u00f3n autom\u00e1tico acepta par\u00e1metros para el t\u00edtulo y el mensaje del banner de inicio de sesi\u00f3n, y conmutadores para volver a los valores predeterminados de Microsoft y forzar un reinicio. Comienza comprobando si se proporcionan estos par\u00e1metros, recortando cualquier espacio en blanco inicial o final. Si faltan par\u00e1metros esenciales y no se utilizan los valores por defecto de Microsoft, el script sale con un mensaje de error.<\/li>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Comprobaci\u00f3n de dominio:<\/strong> la funci\u00f3n Test-IsDomainJoined comprueba si el dispositivo forma parte de un dominio. En caso afirmativo, el script para desactivar el inicio de sesi\u00f3n autom\u00e1tico aconseja utilizar la directiva de grupo para la configuraci\u00f3n del banner de inicio de sesi\u00f3n y finaliza. Esto garantiza el cumplimiento de las pol\u00edticas del dominio y evita conflictos.<\/li>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Modificaci\u00f3n de claves de registro:<\/strong> La funci\u00f3n Set-RegKey se utiliza para crear o modificar claves de registro que controlan la configuraci\u00f3n del inicio de sesi\u00f3n autom\u00e1tico. Si el inicio de sesi\u00f3n autom\u00e1tico est\u00e1 activado (el valor de registro AutoAdminLogon no es 0), se establece en 0. Del mismo modo, si el inicio de sesi\u00f3n sin contrase\u00f1a est\u00e1 activado, se desactiva estableciendo el valor DevicePasswordLessBuildVersion en 2.<\/li>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Exportaci\u00f3n y modificaci\u00f3n de pol\u00edticas de seguridad:<\/strong> el script para desactivar el inicio de sesi\u00f3n autom\u00e1tico exporta la pol\u00edtica de seguridad actual utilizando SecEdit.exe y procesa el archivo de configuraci\u00f3n para incluir o modificar la configuraci\u00f3n del banner de inicio de sesi\u00f3n. Si se solicitan los valores predeterminados de Microsoft, elimina cualquier configuraci\u00f3n de banner de inicio de sesi\u00f3n existente. En caso contrario, actualiza el LegalNoticeCaption y el LegalNoticeText con el t\u00edtulo y el mensaje proporcionados.<\/li>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Aplicaci\u00f3n de la pol\u00edtica actualizada:<\/strong> tras modificar el archivo de configuraci\u00f3n, el script para desactivar el inicio de sesi\u00f3n autom\u00e1tico aplica la pol\u00edtica de seguridad actualizada mediante SecEdit.exe. Si se fuerza un reinicio, programa un reinicio del sistema para garantizar que los cambios surtan efecto inmediatamente.<\/li>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Pasos finales:<\/strong> el script proporciona informaci\u00f3n a lo largo de su ejecuci\u00f3n, indicando el estado de cada operaci\u00f3n y los errores encontrados.<\/li>\n<\/ol>\n<h2>Posibles casos de uso<\/h2>\n<p>Imag\u00ednate a un profesional de TI que gestiona una flota de port\u00e1tiles para una entidad financiera. Garantizar que cada dispositivo requiera un inicio de sesi\u00f3n al arrancar es crucial para proteger los datos financieros confidenciales. Mediante este script para desactivar el inicio de sesi\u00f3n autom\u00e1tico, el profesional de TI puede automatizar el proceso en todos los dispositivos, garantizando el cumplimiento de las pol\u00edticas de seguridad y ahorrando tiempo en la configuraci\u00f3n manual.<\/p>\n<h2>Comparaciones<\/h2>\n<p>Aunque las pol\u00edticas de grupo son el m\u00e9todo preferido para los dispositivos unidos a un dominio, este script para desactivar el inicio de sesi\u00f3n autom\u00e1tico ofrece una soluci\u00f3n sencilla para sistemas independientes o peque\u00f1os grupos de trabajo. Comparado con la edici\u00f3n manual del registro o el uso de herramientas de terceros, este script es m\u00e1s eficiente y reduce el riesgo de error humano.<\/p>\n<h2>FAQ<\/h2>\n<ul>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\"><strong>\u00bfSe puede utilizar este script en todas las versiones de Windows?<\/strong> Este script para desactivar el inicio de sesi\u00f3n autom\u00e1tico est\u00e1 dise\u00f1ado para Windows 10 y Windows Server 2016 y versiones posteriores.<\/li>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\"><strong>\u00bfQu\u00e9 ocurre si proporciono tanto los valores predeterminados de Microsoft como un t\u00edtulo\/mensaje personalizado?<\/strong> El script para desactivar el inicio de sesi\u00f3n autom\u00e1tico arrojar\u00e1 un error, ya que no est\u00e1 pensado para mezclar estas configuraciones.<\/li>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\"><strong>\u00bfEs necesario reiniciar?<\/strong> Se recomienda reiniciar para que la configuraci\u00f3n del banner de inicio de sesi\u00f3n surta efecto.<\/li>\n<li data-leveltext=\"%1.\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:0,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769242&quot;:[65533,0],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;%1.&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\"><strong>\u00bfPuede ejecutarse sin privilegios de administrador?<\/strong> No, el script para desactivar el inicio de sesi\u00f3n autom\u00e1tico debe ejecutarse con privilegios de administrador para modificar la configuraci\u00f3n del registro y aplicar pol\u00edticas de seguridad.<\/li>\n<\/ul>\n<h2>Implicaciones<\/h2>\n<p>Desactivar el inicio de sesi\u00f3n autom\u00e1tico e implementar un banner de inicio de sesi\u00f3n mejora la seguridad al garantizar que los usuarios se autentiquen y reconozcan cualquier aviso de seguridad. Esta pr\u00e1ctica reduce el riesgo de acceso no autorizado y garantiza el cumplimiento de los protocolos de seguridad.<\/p>\n<h2>Recomendaciones<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\">Prueba siempre el script en una sola m\u00e1quina antes de desplegarlo ampliamente.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\">Utiliza t\u00edtulos y mensajes descriptivos para que el banner de inicio de sesi\u00f3n proporcione instrucciones o advertencias claras a los usuarios.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"2\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">Programa revisiones peri\u00f3dicas de las pol\u00edticas de seguridad para adaptarse a la evoluci\u00f3n de las amenazas a la seguridad.<\/li>\n<\/ul>\n<h2>Reflexiones finales<\/h2>\n<p>Para los profesionales de TI y los MSP, <a href=\"https:\/\/www.ninjaone.com\/es\/blog\/como-combatir-amenazas-ciberseguridad\/\" target=\"_blank\" rel=\"noopener\">garantizar unas medidas de seguridad s\u00f3lidas<\/a> es primordial. Desactivar el inicio de sesi\u00f3n autom\u00e1tico e implementar banners de inicio de sesi\u00f3n son pasos fundamentales para proteger los datos confidenciales. Este <a href=\"https:\/\/www.ninjaone.com\/es\/it-hub\/endpoint-management\/powershell\/\" target=\"_blank\" rel=\"noopener\">script de PowerShell<\/a> para desactivar el inicio de sesi\u00f3n autom\u00e1tico proporciona una forma <a href=\"https:\/\/www.ninjaone.com\/es\/eficiencia\/\" target=\"_blank\" rel=\"noopener\">eficaz<\/a> y <a href=\"https:\/\/www.ninjaone.com\/es\/rmm\/automatizacion-de-ti\/\" target=\"_blank\" rel=\"noopener\">automatizada<\/a> de lograr estos objetivos. Adem\u00e1s, el uso de herramientas como NinjaOne puede mejorar a\u00fan m\u00e1s la gesti\u00f3n de la seguridad al proporcionar capacidades de control y supervisi\u00f3n centralizadas.<\/p>\n","protected":false},"author":35,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"","_lmt_disable":""},"operating_system":[4212],"use_cases":[4267,4264],"class_list":["post-353785","script_hub","type-script_hub","status-publish","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/script_hub\/353785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/comments?post=353785"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/media?parent=353785"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/operating_system?post=353785"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/use_cases?post=353785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}