{"id":208601,"date":"2023-09-11T11:07:07","date_gmt":"2023-09-11T11:07:07","guid":{"rendered":"https:\/\/www.ninjaone.com\/script-hub\/borrar-disco-duro-powershell\/"},"modified":"2024-03-04T16:28:17","modified_gmt":"2024-03-04T16:28:17","slug":"borrar-disco-duro-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/es\/script-hub\/borrar-disco-duro-powershell\/","title":{"rendered":"C\u00f3mo borrar de forma segura un disco duro con PowerShell en Windows"},"content":{"rendered":"<p><span class=\"TextRun SCXW3111736 BCX0\" lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW3111736 BCX0\">En el momento que estamos viviendo en materia de seguridad de los datos, borrar los datos de un disco duro de forma correcta es fundamental. Para los profesionales de TI y los proveedores de servicios gestionados (MSP), disponer de herramientas fiables para estas tareas es esencial. En este post, <\/span><span class=\"NormalTextRun SCXW3111736 BCX0\">veremos en detalle <\/span><span class=\"NormalTextRun SCXW3111736 BCX0\">un vers\u00e1til <strong>script PowerShell, dise\u00f1ado para borrar los datos de un disco duro de forma segura y eficaz<\/strong>. <\/span><span class=\"NormalTextRun SCXW3111736 BCX0\">Tambi\u00e9n<\/span><span class=\"NormalTextRun SCXW3111736 BCX0\">te <\/span><span class=\"NormalTextRun SCXW3111736 BCX0\">proporcionaremo s<\/span><span class=\"NormalTextRun SCXW3111736 BCX0\">consejos esenciales para garantizar el \u00e9xito de la ejecuci\u00f3n y la eliminaci\u00f3n de los datos.<\/span><\/span><\/p>\n<h2>El poder de PowerShell para la gesti\u00f3n de discos<\/h2>\n<p><span class=\"TextRun SCXW129074721 BCX0\" lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW129074721 BCX0\">PowerShell, el potente lenguaje de scripting de Microsoft, ofrece amplias posibilidades para gestionar y proteger datos. Gracias a sus s\u00f3lidas funcionalidades, como la capacidad de formatear discos y borrar unidades de disco duro, PowerShell<\/span><span class=\"NormalTextRun ContextualSpellingAndGrammarErrorV2Themed SCXW129074721 BCX0\">se convierte<\/span><span class=\"NormalTextRun SCXW129074721 BCX0\">en una herramienta inestimable para cualquiera que se ocupe de tareas frecuentes de gesti\u00f3n de datos.<\/span><\/span><\/p>\n<h2>Descubrir el potencial del script PowerShell para borrar los datos de un disco duro de forma remota<\/h2>\n<p><span data-contrast=\"auto\">El script PowerShell en cuesti\u00f3n est\u00e1 dise\u00f1ado para ejecutar un borrado remoto en un dispositivo. Es capaz de ejecutar varios m\u00e9todos, cada uno de los cuales proporciona distintos niveles de eliminaci\u00f3n de datos y restablecimiento del sistema para adaptarse a los diferentes requisitos de seguridad de los datos.<\/span><\/p>\n<p><span data-contrast=\"auto\">Pero \u00bfc\u00f3mo puedes estar seguro de que este script se ejecuta correctamente y de que todos los datos se borran con \u00e9xito del disco duro? Aqu\u00ed tienes algunos consejos:<\/span><\/p>\n<ol>\n<li><span data-contrast=\"auto\"><strong>Comprueba la compatibilidad:<\/strong> aseg\u00farate de que el sistema de destino es compatible con el m\u00e9todo elegido. Por ejemplo, los m\u00e9todos \u00abWipeProtected\u00bb y \u00abWipePersistUserData\u00bb solo son compatibles con determinadas versiones de compilaci\u00f3n de Windows 10 o superiores.<\/span><\/li>\n<\/ol>\n<ol start=\"2\">\n<li><span data-contrast=\"auto\"><strong>Verifica el nombre del ordenador:<\/strong> el par\u00e1metro ComputerName debe coincidir con el nombre del ordenador en el que se ejecuta el script. Si no coincide, el script saldr\u00e1 sin realizar ning\u00fan cambio. El interruptor ComputerNameBypass se puede utilizar para excluir esta opci\u00f3n.<\/span><\/li>\n<\/ol>\n<ol start=\"3\">\n<li><span data-contrast=\"auto\"><strong>Prueba antes de la implantaci\u00f3n:<\/strong> prueba siempre el script en un entorno controlado antes de desplegarlo en un entorno de producci\u00f3n. Esto ayuda a identificar y rectificar cualquier problema antes de que afecte a los sistemas cr\u00edticos.<\/span><\/li>\n<\/ol>\n<ol start=\"4\">\n<li><span data-contrast=\"auto\"><strong>Supervisa la ejecuci\u00f3n del script:<\/strong> vigila la ejecuci\u00f3n del script. Presta atenci\u00f3n a los errores o excepciones lanzados por el script. Estos mensajes pueden aportar informaci\u00f3n valiosa sobre cualquier problema que pueda surgir.<\/span><\/li>\n<\/ol>\n<ol start=\"5\">\n<li><span data-contrast=\"auto\"><strong>Comprueba que se hayan borrado los datos:<\/strong> una vez ejecutado el script, comprueba que los datos se hayan borrado correctamente. Puedes hacerlo intentando recuperar datos de la unidad. Si la recuperaci\u00f3n es imposible, el borrado de datos puede considerarse un \u00e9xito.<\/span><\/li>\n<\/ol>\n<ol start=\"6\">\n<li><span data-contrast=\"auto\"><strong>Documenta el proceso:<\/strong> lleva un registro de todo el proceso, desde la ejecuci\u00f3n inicial del script hasta la verificaci\u00f3n del borrado de datos. Esta documentaci\u00f3n puede ser un recurso valioso para futuras referencias o en caso de auditor\u00edas.<\/span><\/li>\n<\/ol>\n<p>El script: borrar datos de un dispositivo Windows de forma remota<br \/>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\"> #Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Remote Wipe a device.\r\n.DESCRIPTION\r\n    Remote Wipe a device via InvokeMethod from a Cim Session. doWipe, doWipeProtected, doWipePersistUserData, and doWipePersistProvisionedData are supported.\r\n    See examples for how to use each.\r\n.EXAMPLE\r\n    -Method Wipe -ComputerName \"PC-001\"\r\n    Runs the doWipe method. Equivalent to running \"Reset this PC &gt; Remove everything\" from the Settings app, with Clean Data set to No and Delete Files set to Yes.\r\n    ComputerName needs to match the computer name of the computer the script is running on. If it doesn't then the script will exit, doing nothing.\r\n.EXAMPLE\r\n    -Method Wipe -ComputerNameBypass\r\n    Runs the doWipe method. Equivalent to running \"Reset this PC &gt; Remove everything\" from the Settings app, with Clean Data set to No and Delete Files set to Yes.\r\n    Will bypass the computer name check and run regards less.\r\n.EXAMPLE\r\n    -Method WipeProtected -ComputerName \"PC-001\"\r\n    Runs the doWipeProtected method. Performs a remote reset on the device and also fully cleans the internal drive.\r\n    Windows 10 build version 1703 and above.\r\n    ComputerName needs to match the computer name of the computer the script is running on. If it doesn't then the script will exit, doing nothing.\r\n.EXAMPLE\r\n    -Method WipePersistUserData\r\n    Runs the doWipeProtected method. Equivalent to selecting \"Reset this PC &gt; Keep my files\" when manually starting a reset from the Settings app.\r\n    Windows 10 build version 1709 and above.\r\n    ComputerName needs to match the computer name of the computer the script is running on. If it doesn't then the script will exit, doing nothing.\r\n.EXAMPLE\r\n    -Method WipePersistProvisionedData\r\n    Runs the doWipeProtected method. Provisioning packages in the %SystemDrive%ProgramDataMicrosoftProvisioning folder will be retained and then applied to the OS after the reset.\r\n    The information that was backed up will be restored and applied to the device when it resumes.\r\n    ComputerName needs to match the computer name of the computer the script is running on. If it doesn't then the script will exit, doing nothing.\r\n.NOTES\r\n    Reference: https:\/\/docs.microsoft.com\/en-us\/windows\/client-management\/mdm\/remotewipe-csp\r\n    Release Notes:\r\n    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(Mandatory = $true)]\r\n    [ValidateSet(\"Wipe\", \"WipeProtected\", \"WipePersistProvisionedData\", \"WipePersistUserData\")]\r\n    [String]\r\n    $Method,\r\n    [Parameter()]\r\n    [String]\r\n    $ComputerName,\r\n    [Parameter()]\r\n    [switch]\r\n    $ComputerNameBypass\r\n)\r\n\r\n# ComputerNameBypass was used, continue on.\r\nif ($PSBoundParameters.ContainsKey(\"ComputerNameBypass\") -and $ComputerNameBypass) {\r\n    Write-Host \"Bypassing Computer Name check.\"\r\n}\r\nelse {\r\n    # If computer name matches, continue on.\r\n    if ($ComputerName -notlike $env:COMPUTERNAME) {\r\n        Write-Error \"Computer Name does not match.\"\r\n        exit 1\r\n    }\r\n}\r\n\r\n# Check if the requested Method is supported or not\r\n$BuildVersion = [System.Environment]::OSVersion.Version.Build\r\nif ($BuildVersion -lt 1703 -and $Method -like \"WipeProtected\") {\r\n    Write-Host \"WipeProtected is only supported on Windows 10 build version 1703 and above.\"\r\n    exit 1\r\n}\r\nif ($BuildVersion -lt 1709 -and $Method -like \"WipePersistUserData\") {\r\n    Write-Host \"WipePersistUserData is only supported on Windows 10 build version 1709 and above.\"\r\n    exit 1\r\n}\r\n\r\n$session = New-CimSession\r\n\r\n$params = New-Object Microsoft.Management.Infrastructure.CimMethodParametersCollection\r\n$param = [Microsoft.Management.Infrastructure.CimMethodParameter]::Create(\"param\", \"\", \"String\", \"In\")\r\n$params.Add($param)\r\n\r\n$CimSplat = @{\r\n    Namespace = \"rootcimv2mdmdmmap\"\r\n    ClassName = \"MDM_RemoteWipe\"\r\n    Filter    = \"ParentID='.\/Vendor\/MSFT' and InstanceID='RemoteWipe'\"\r\n}\r\n\r\ntry {\r\n    $instance = Get-CimInstance @CimSplat\r\n    $session.InvokeMethod($CimSplat[\"Namespace\"], $instance, \"do$($Method)Method\", $params)\r\n}\r\ncatch {\r\n    Write-Error $_\r\n    exit 1\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<br \/>\n<div class=\"in-context-cta\"><p>Accede a m\u00e1s de 700 scripts en el Dojo de NinjaOne <a href=\"https:\/\/www.ninjaone.com\/es\/prueba-gratuita-formulario\/\">Accede aqu\u00ed<\/a><\/p>\n<\/div><\/p>\n<p><span class=\"TextRun SCXW186655300 BCX0\" lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun CommentStart SCXW186655300 BCX0\">Los scripts de PowerShell, como el que se analiza en esta entrada del blog, pueden ser potentes herramientas para los profesionales de TI y los MSP, <\/span><span class=\"NormalTextRun SCXW186655300 BCX0\">proporcionando <\/span><span class=\"NormalTextRun SCXW186655300 BCX0\">eficacia y una s\u00f3lida seguridad de los datos. Teniendo una comprensi\u00f3n clara del script y siguiendo estos consejos, puedes garantizar el \u00e9xito de la ejecuci\u00f3n y el borrado seguro de datos. En el \u00e1mbito de la gesti\u00f3n de datos, disponer de herramientas y conocimientos tan fiables tiene un valor incalculable.<\/span><\/span><span class=\"EOP SCXW186655300 BCX0\" data-ccp-props=\"{}\">\u00a0<\/span> <span data-contrast=\"auto\">Puede que te est\u00e9s preguntando: \u00ab\u00bfY para borrar los datos de un disco duro de Mac?\u00bb. Tambi\u00e9n tenemos respuesta a esto. \u00c9chale un vistazo a esta entrada: <a href=\"https:\/\/www.ninjaone.com\/blog\/wipe-a-mac-hard-drive-remotely-bash-script\/\">\u00abC\u00f3mo borrar un disco duro en Mac con un script de bash\u00bb<\/a>.<\/span><\/p>\n<h2>C\u00f3mo puede ayudar NinjaOne<\/h2>\n<p>Para las organizaciones que buscan llevar la seguridad de sus datos y la gesti\u00f3n de TI al siguiente nivel, la integraci\u00f3n de una soluci\u00f3n como NinjaOne puede marcar una diferencia significativa. Aunque los scripts de PowerShell son potentes para tareas como la limpieza de discos, gestionarlos en gran n\u00famero de dispositivos puede resultar engorroso. NinjaOne simplifica todo esto ofreciendo <a href=\"https:\/\/www.ninjaone.com\/es\/rmm\/automatizacion-de-ti\/\">capacidades centralizadas de despliegue y automatizaci\u00f3n de scripts<\/a>. Puedes desplegar los scripts PowerShell para borrar datos de forma remota en varios dispositivos, todo desde un \u00fanico panel de control.<\/p>\n<p>Adem\u00e1s, NinjaOne ofrece informes y an\u00e1lisis avanzados para que puedas verificar f\u00e1cilmente el \u00e9xito de las operaciones de borrado de datos y mantener registros de cumplimiento. En caso de que el script se encuentre con problemas o excepciones, el monitoreo en tiempo real de NinjaOne te alertar\u00e1, permitiendo una r\u00e1pida intervenci\u00f3n. Esto minimiza los riesgos y garantiza que el proceso de eliminaci\u00f3n de datos sea exhaustivo y seguro.<\/p>\n<p>Por lo tanto, si eres un profesional de TI o un proveedor de servicios gestionados, la integraci\u00f3n de NinjaOne en tu gesti\u00f3n de datos y pr\u00e1cticas de seguridad puede ofrecer una capa adicional de eficiencia y fiabilidad. No se trata s\u00f3lo de ejecutar un script; se trata de gestionarlo eficazmente en toda la organizaci\u00f3n, y NinjaOne puede ayudarte a hacerlo. Mira <a href=\"https:\/\/www.ninjaone.com\/es\/supervision-y-gestion-de-endpoints-prueba-gratuita\/\">una demostraci\u00f3n<\/a> y descubre por qu\u00e9 NinjaOne ha sido votado como el <a href=\"https:\/\/www.ninjaone.com\/es\/supervision-gestion-de-endpoints\/\">software de gesti\u00f3n de endpoints<\/a> n.\u00ba 1 en G2 Crowd.<\/p>\n","protected":false},"author":35,"featured_media":206766,"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":"no","_lmt_disable":""},"operating_system":[4212],"use_cases":[4222],"class_list":["post-208601","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/script_hub\/208601","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=208601"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/media\/206766"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/media?parent=208601"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/operating_system?post=208601"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/use_cases?post=208601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}