Bekijk een demo×
×

Zie NinjaOne in actie!

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

Ongebruikte Lokale Accounts op Windows-systemen Identificeren en Beheren

Als u een IT-professional of een Managed Service Provider (MSP) bent, zou het concept van ongebruikte lokale accounts een belletje moeten doen rinkelen. Simpel gezegd zijn ongebruikte lokale accounts accounts die gedurende een bepaalde tijd niet zijn gebruikt (vaak gedefinieerd door het beleid van uw organisatie). Deze ogenschijnlijk onschuldige accounts kunnen in feite een aanzienlijk beveiligingsrisico vormen en dienen als een achterdeur voor aanvallers om ongeautoriseerde toegang tot een systeem te krijgen. Vandaag verkennen we een PowerShell-script dat is ontworpen om deze potentiële beveiligingsleemten te identificeren en te beheren.

Het script: Een gedetailleerd onderzoek

Het script Test-UnusedLocalAccounts.ps1 werkt onder PowerShell 5.1 en biedt een gestroomlijnde aanpak voor het beheren van slapende accounts. Het begint met controleren of het commando Get-LocalUser beschikbaar is op uw systeem. Dit is cruciaal omdat de hele functionaliteit op dit commando is gebouwd. Eenmaal bevestigd, doorloopt het script alle lokale accounts om de accounts te identificeren die een bepaald aantal dagen (standaard 30 dagen) geen activiteit hebben gezien. De kers op de taart? Het script stuurt een overzichtelijke lijst van deze inactieve accounts rechtstreeks naar uw console.

Het Script: Conditioneringsscript voor Ongebruikte Lokale Accounts op Windows

#Requires -Version 5.1

<#
.SYNOPSIS
    Condition script for unused local account on windows
.DESCRIPTION
    Condition script for unused local account on windows
.EXAMPLE
     -Days 30
    Checks for accounts that have not logged in for more than 30 days
.EXAMPLE
    PS C:> Test-UnusedLocalAccounts.ps1 -Days 30
    Checks for accounts that have not logged in for more than 30 days
.OUTPUTS
    None
.NOTES
    Minimum supported OS: Windows 10, Server 2016
    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()]
    [int]
    $Days = 30
)

begin {
    function Test-StringEmpty {
        param([string]$Text)
        # Returns true if string is empty, null, or whitespace
        process { [string]::IsNullOrEmpty($Text) -or [string]::IsNullOrWhiteSpace($Text) }
    }
    if (-not $(Test-StringEmpty -Text $env:Days)) {
        $Days = $env:Days
    }
}
process {
    # Check if Get-LocalUser is available on this system
    if (-not $(Get-Command -Name "Get-LocalUser" -ErrorAction SilentlyContinue)) {
        Write-Error "The command Get-LocalUser is not available on this system."
        exit 2
    }

    $UnusedAccounts = Get-LocalUser |
        Where-Object {
            ($(Test-StringEmpty -Text $_.LastLogon) -or $_.LastLogon -le (Get-Date).AddDays(-$Days)) -and
            $_.Enabled
        } |
        Select-Object Name, LastLogon |
        ForEach-Object {
            [PSCustomObject]@{
                Name      = $_.Name
                LastLogon = $_.LastLogon
            }
        }
    if ($UnusedAccounts) {
        Write-Host "Accounts that have not logged in for the past $Days days:"
        $UnusedAccounts | ForEach-Object {
            Write-Host "$($_.Name): $($_.LastLogon)"
        }
        exit 1
    }
    exit 0
}
end {
    $ScriptVariables = @(
        [PSCustomObject]@{
            name           = "Days"
            calculatedName = "days"
            required       = $false
            defaultValue   = [PSCustomObject]@{
                type  = "TEXT"
                value = "30"
            }
            valueType      = "TEXT"
            valueList      = $null
            description    = "Accounts older than this number in days."
        }
    )
}

 

Toegang tot meer dan 300 scripts in de NinjaOne Dojo

Toegang Krijgen

Belangrijkste Voordelen: Verder dan de Basis

Beveiligingen

Zoals eerder vermeld, worden ongebruikte lokale accounts vaak niet bewaakt, waardoor ze potentiële toegangspunten worden voor cybercriminelen. Dit script helpt bij het proactief identificeren van deze accounts.

Efficiëntie

Wat uren handmatig werk kan kosten, kost minuten met dit script. Vooral voor MSP’s die meerdere klantaccounts beheren, is efficiëntie essentieel.

Flexibiliteit

U zit niet vast aan een periode van 30 dagen. U kunt het tijdsbestek aanpassen aan het beleid van uw organisatie.

Uitgebreide Functies

Het identificeren van ongebruikte accounts is belangrijk, maar het is net zo belangrijk om op basis van deze informatie actie te ondernemen. Het script kan ook worden geconfigureerd om de resultaten naar een bestand te exporteren of een e-mailmelding te sturen wanneer ongebruikte accounts worden ontdekt. Dit verbetert uw vermogen om deze accounts effectief bij te houden en te beheren.

Hoe te Gebruiken

Voer het volgende commando in om het script te implementeren:

Misschien bent u ook geïnteresseerd in ons blogartikel over het uitschakelen van een lokale account in Windows met PowerShell.

NinjaOne. Uw Arsenaal Uitbreiden

Hoewel ons besproken PowerShell-script een hulpmiddel van onschatbare waarde is, is het slechts één stukje van de puzzel. Platformen zoals NinjaOne bieden een uitgebreidere aanpak, waarmee u niet alleen ongebruikte lokale accounts kunt beheren, maar uw hele IT-ecosysteem. NinjaOne kan zelfs scripts zoals Test-UnusedLocalAccounts.ps1 op meerdere systemen tegelijk uitvoeren.

Slotopmerkingen

In het grote geheel van cyberbeveiliging telt elk klein beetje. Ongebruikte lokale accounts op Windows-systemen lijken triviaal, maar kunnen uw achilleshiel worden als u er niets aan doet. Het script Test-UnusedLocalAccounts.ps1 is een robuuste, geautomatiseerde oplossing voor dit vaak over het hoofd geziene aspect van systeembeheer. En in combinatie met platforms als NinjaOne en andere tools beschikken IT-professionals en MSP’s over een uitgebreide toolkit om ervoor te zorgen dat hun netwerken ongecompromitteerd blijven.

Dus, daar hebt u het. Rust uzelf uit met de juiste tools en kennis om uw IT-omgeving effectief te beveiligen. Blijf deze pagina volgen voor meer IT-oplossingen voor bedrijven.

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

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).