Bekijk een demo×
×

Zie NinjaOne in actie!

Door dit formulier in te dienen geef ik aan akkoord te gaan met het privacybeleid van NinjaOne.

Een Windows harde schijf veilig wissen met PowerShell

In het huidige tijdperk van gegevensbeveiliging is de juiste verwijdering van gegevens op harde schijven van cruciaal belang. Voor IT-professionals en Managed Service Providers (MSP’s) is het essentieel om betrouwbare tools te hebben voor deze taken. In deze blogpost, duiken wein de details van een veelzijdig PowerShell-script dat is ontworpen voor veilig en efficiënt wissen van schijven. We gevenookessentiële tipsvoor een succesvolle uitvoering en gegevensverwijdering.

De kracht van PowerShell voor schijfbeheer

PowerShell, de krachtige scripttaal van Microsoft, biedt uitgebreide mogelijkheden voor het beheren en beveiligen van gegevens. Met de robuuste functionaliteiten, zoals de mogelijkheid om schijven te formatteren en harde schijven te wissen,wordtPowerShell een hulpmiddel van onschatbare waarde voor iedereen die te maken heeft met frequente taken op het gebied van gegevensbeheer.

Het potentieel van het PowerShell-script voor wissen op afstand ontsluiten

Het PowerShell-script dat we hier bespreken is gemaakt om een apparaat op afstand te wissen. Het is in staat om verschillende methoden uit te voeren, die elk verschillende niveaus van gegevensverwijdering en systeemreset bieden om te voldoen aan verschillende vereisten voor gegevensbeveiliging.

Maar hoe zorgt u ervoor dat dit script correct wordt uitgevoerd en alle gegevens met succes van de harde schijf worden gewist? Hier zijn enkele tips:

  1. Compatibiliteit controleren: Zorg ervoor dat het doelsysteem compatibel is met de gekozen methode. De methoden ‘WipeProtected’ en ‘WipePersistUserData’ worden bijvoorbeeld alleen ondersteund op specifieke Windows 10 build-versies of hoger.
  1. Computernaam controleren: De parameter ComputerName moet overeenkomen met de naam van de computer waarop het script wordt uitgevoerd. Als dat niet het geval is, wordt het script afgesloten zonder wijzigingen aan te brengen. De ComputerNameBypass schakelaar kan gebruikt worden om dit op te heffen.
  1. Test voor implementatie: Test het script altijd in een gecontroleerde omgeving voordat u het inzet in een productieomgeving. Dit helpt om problemen op te sporen en te verhelpen voordat ze kritieke systemen beïnvloeden.
  1. Scriptuitvoering bewaken: Houd de uitvoering van het script in de gaten. Let op fouten of uitzonderingen die door het script worden gegooid. Deze berichten kunnen waardevolle inzichten geven in eventuele problemen.
  1. Gegevens wissen controleren: Controleer nadat het script is uitgevoerd of het wissen van de gegevens is gelukt. Dit kan worden gedaan door te proberen gegevens van de schijf te halen. Als terughalen onmogelijk is, kan het wissen van de gegevens als geslaagd worden beschouwd.
  1. Documenteer het proces: Houd het hele proces bij, van de eerste uitvoering van het script tot de verificatie van het wissen van de gegevens. Deze documentatie kan een waardevolle bron zijn voor toekomstige referentie of in geval van audits.

Het script: Een Windows-apparaat op afstand wissen

 #Requires -Version 5.1

<#
.SYNOPSIS
    Remote Wipe a device.
.DESCRIPTION
    Remote Wipe a device via InvokeMethod from a Cim Session. doWipe, doWipeProtected, doWipePersistUserData, and doWipePersistProvisionedData are supported.
    See examples for how to use each.
.EXAMPLE
    -Method Wipe -ComputerName "PC-001"
    Runs the doWipe method. Equivalent to running "Reset this PC > Remove everything" from the Settings app, with Clean Data set to No and Delete Files set to Yes.
    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.
.EXAMPLE
    -Method Wipe -ComputerNameBypass
    Runs the doWipe method. Equivalent to running "Reset this PC > Remove everything" from the Settings app, with Clean Data set to No and Delete Files set to Yes.
    Will bypass the computer name check and run regards less.
.EXAMPLE
    -Method WipeProtected -ComputerName "PC-001"
    Runs the doWipeProtected method. Performs a remote reset on the device and also fully cleans the internal drive.
    Windows 10 build version 1703 and above.
    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.
.EXAMPLE
    -Method WipePersistUserData
    Runs the doWipeProtected method. Equivalent to selecting "Reset this PC > Keep my files" when manually starting a reset from the Settings app.
    Windows 10 build version 1709 and above.
    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.
.EXAMPLE
    -Method WipePersistProvisionedData
    Runs the doWipeProtected method. Provisioning packages in the %SystemDrive%ProgramDataMicrosoftProvisioning folder will be retained and then applied to the OS after the reset.
    The information that was backed up will be restored and applied to the device when it resumes.
    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.
.NOTES
    Reference: https://docs.microsoft.com/en-us/windows/client-management/mdm/remotewipe-csp
    Release Notes:
    Initial Release
By 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.
    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. 
    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. 
    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. 
    Warranty Disclaimer: The script is provided “as is” and “as available”, 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. 
    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. 
    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. 
    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).
#>

[CmdletBinding()]
param (
    [Parameter(Mandatory = $true)]
    [ValidateSet("Wipe", "WipeProtected", "WipePersistProvisionedData", "WipePersistUserData")]
    [String]
    $Method,
    [Parameter()]
    [String]
    $ComputerName,
    [Parameter()]
    [switch]
    $ComputerNameBypass
)

# ComputerNameBypass was used, continue on.
if ($PSBoundParameters.ContainsKey("ComputerNameBypass") -and $ComputerNameBypass) {
    Write-Host "Bypassing Computer Name check."
}
else {
    # If computer name matches, continue on.
    if ($ComputerName -notlike $env:COMPUTERNAME) {
        Write-Error "Computer Name does not match."
        exit 1
    }
}

# Check if the requested Method is supported or not
$BuildVersion = [System.Environment]::OSVersion.Version.Build
if ($BuildVersion -lt 1703 -and $Method -like "WipeProtected") {
    Write-Host "WipeProtected is only supported on Windows 10 build version 1703 and above."
    exit 1
}
if ($BuildVersion -lt 1709 -and $Method -like "WipePersistUserData") {
    Write-Host "WipePersistUserData is only supported on Windows 10 build version 1709 and above."
    exit 1
}

$session = New-CimSession

$params = New-Object Microsoft.Management.Infrastructure.CimMethodParametersCollection
$param = [Microsoft.Management.Infrastructure.CimMethodParameter]::Create("param", "", "String", "In")
$params.Add($param)

$CimSplat = @{
    Namespace = "rootcimv2mdmdmmap"
    ClassName = "MDM_RemoteWipe"
    Filter    = "ParentID='./Vendor/MSFT' and InstanceID='RemoteWipe'"
}

try {
    $instance = Get-CimInstance @CimSplat
    $session.InvokeMethod($CimSplat["Namespace"], $instance, "do$($Method)Method", $params)
}
catch {
    Write-Error $_
    exit 1
}

 


Toegang tot meer dan 700 scripts in de NinjaOne Dojo

Toegang krijgen

PowerShell-scripts, zoals het script dat in deze blogpost wordt besproken, kunnen krachtige hulpmiddelen zijn voor IT-professionals en MSP’s, die zorgen voorefficiëntie en robuuste gegevensbeveiliging. Met een duidelijk begrip van het script en door deze tips op te volgen, kunt u zorgen voor een succesvolle uitvoering en veilige gegevensverwijdering. Op het gebied van gegevensbeheer zijn dergelijke betrouwbare tools en kennis van onschatbare waarde. 

U vraagt zich misschien af hoe het zit met het wissen van de harde schijf van een Mac? Bekijk onze blogpost over “Hoe een Mac harde schijf wissen met een Bash Script“.

Hoe NinjaOne kan helpen

Voor organisaties die hun gegevensbeveiliging en IT-beheer naar een hoger niveau willen tillen, kan de integratie van een oplossing als NinjaOne een aanzienlijk verschil maken. Hoewel PowerShell scripts krachtig zijn voor taken zoals het wissen van schijven, kan het beheren van deze scripts op een groot aantal apparaten lastig zijn. NinjaOne stroomlijnt dit door gecentraliseerde scriptimplementatie en automatiseringsmogelijkheden te bieden. U kunt zich PowerShell-scripts implementeren om gegevens op afstand te wissen op meerdere apparaten, allemaal vanaf één dashboard.

Bovendien biedt NinjaOne geavanceerde rapportage en analyses, zodat u eenvoudig het succes van uw data wipe activiteiten kunt controleren en compliance records kunt bijhouden. Als het script tegen problemen of uitzonderingen aanloopt, zal de realtime bewaking van NinjaOne u waarschuwen, zodat u snel kunt ingrijpen. Dit minimaliseert de risico’s en zorgt ervoor dat uw gegevensverwijderingsproces grondig en veilig verloopt.

Dus of u nu een IT-professional of een Managed Service Provider bent, het integreren van NinjaOne in uw gegevensbeheer en beveiligingspraktijken kan een extra laag van efficiëntie en betrouwbaarheid bieden. Het gaat niet alleen om het uitvoeren van een script; het gaat om het effectief beheren ervan binnen uw organisatie en NinjaOne kan daarbij helpen. Bekijk een demo om te zien waarom NinjaOne is verkozen tot de #1 Eindpuntbeheer Software op G2 Crowd.

Volgende stappen

Het opbouwen van een efficiënt en effectief IT-team vereist een gecentraliseerde oplossing die fungeert als uw kerndienstleveringstool. NinjaOne stelt IT-teams in staat om al hun apparaten te monitoren, beheren, beveiligen en ondersteunen, waar ze ook zijn, zonder de noodzaak van complexe on-premises infrastructuur.

Leer meer over NinjaOne Endpoint Management, bekijk een live rondleiding, of start uw gratis trial van het NinjaOne-platform

Categorieën:

Dit vindt u misschien ook leuk

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • 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.
  • 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.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, 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.
  • 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.
  • 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.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).