Demo ansehen×
×

Sehen Sie NinjaOne in Aktion!

Mit dem Absenden dieses Formulars akzeptiere ich die Datenschutzerklärung von NinjaOne.

Erkennen und Verwalten von ungenutzten lokalen Benutzerkonten auf Windows-Systemen

Wenn Sie ein IT-Experte oder ein Managed Service Provider (MSP) sind, sollte Ihnen der Begriff der ungenutzten lokalen Konten vertraut sein. Kurz gesagt, ungenutzte lokale Konten sind solche, die für eine gewisse Zeit nicht aktiv genutzt wurden – eine Zeitspanne, die oft durch die Richtlinien Ihrer Unternehmen festgelegt ist. Diese scheinbar harmlosen Konten können tatsächlich erhebliche Sicherheitsrisiken darstellen, indem sie als Hintertür für Angreifer dienen, um unbefugten Zugriff auf ein System zu erlangen. In diesem Zusammenhang werden wir heute ein PowerShell-Skript genauer untersuchen, das eigens dazu konzipiert ist, diese potenziellen Sicherheitslücken zu identifizieren und zu handhaben.

Das Skript: Eine Umfassende Analyse

Das Skript Test-UnusedLocalAccounts.ps1 läuft unter PowerShell 5.1 und bietet einen optimierten Ansatz für die Verwaltung inaktiver Konten. Zunächst wird überprüft, ob der Befehl Get-LocalUser auf Ihrem System verfügbar ist. Dies ist entscheidend, da die gesamte Funktionalität auf diesem Befehl aufbaut. Nach der Bestätigung durchläuft das Skript alle lokalen Konten, um diejenigen zu ermitteln, die innerhalb eines festgelegten Zeitraums (standardmäßig 30 Tage) keine Aktivität aufweisen. Das besondere Highlight? Das Skript generiert eine gut strukturierte Liste dieser inaktiven Konten direkt in Ihrer Konsole.

Das Skript: Skript zur Überprüfung von ungenutzten lokalen Konten unter 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."
        }
    )
}

 

Zugriff auf über 300 Skripte im NinjaOne Dojo

Zugang erhalten

Wesentliche Vorteile: Über das Grundlegende hinaus

Sicherheit

Wie bereits vorher erwähnt, bleiben inaktive lokale Konten oft unbeobachtet und können zu potenziellen Eintrittspunkten für Cyberkriminelle werden. Dieses Skript hilft dabei, diese Konten proaktiv zu identifizieren.

Effizienz

Was Stunden manueller Arbeit in Anspruch nehmen könnte, dauert mit diesem Skript nur wenige Minuten. Effizienz ist von besonderer Bedeutung, insbesondere für MSPs, die die Konten mehrerer Kunden verwalten.

Flexibilität

Sie sind nicht auf einen Zeitraum von 30 Tagen beschränkt. Entsprechend den Vorgaben Ihres Unternehmens können Sie den Zeitraum individuell anpassen.

Erweiterte Funktionen

Obwohl das Identifizieren von ungenutzten Konten von großer Bedeutung ist, ist es ebenso entscheidend, auf diese Informationen zu reagieren. Das Skript kann ebenfalls so konfiguriert werden, dass die Ergebnisse in eine Datei exportiert oder eine E-Mail-Benachrichtigung versendet wird, wenn ungenutzte Konten entdeckt werden. Dies steigert die Möglichkeit, diese Konten effektiv zu verfolgen und zu verwalten, ohne menschliches Eingreifen.

Anwendungshinweise

Um das Skript einzusetzen, geben Sie folgenden Befehl ein:

Vielleicht interessieren Sie sich auch für unseren Blog-Artikel, „Wie man ein lokales Konto in Windows mit PowerShell deaktiviert“.

NinjaOne: Erweitern Sie Ihre Möglichkeiten

Obwohl unser besprochenes PowerShell-Skript ein unschätzbares Werkzeug ist, ist es nur ein Teil des Ganzen. Dienste wie NinjaOne bieten eine ganzheitlichere Herangehensweise, mit der Sie nicht nur ungenutzte lokale Konten, sondern auch Ihre gesamte IT-Systemumgebung verwalten können. NinjaOne kann sogar Skripte wie Test-UnusedLocalAccounts.ps1 auf mehreren Systemen gleichzeitig ausführen.

Schlussbemerkungen

In der Gesamtbetrachtung der Cybersicherheit ist jeder noch so kleine Beitrag von Bedeutung. Ungenutzte lokale Konten auf Windows-Systemen mögen auf den ersten Blick nebensächlich erscheinen, könnten jedoch zu einem erheblichen Schwachpunkt werden, wenn sie nicht behandelt werden. Das Skript Test-UnusedLocalAccounts.ps1 ist eine robuste, automatisierte Lösung für diesen oft übersehenen Aspekt der Systemverwaltung. Und wenn es in Verbindung mit Plattformen wie NinjaOne und anderen Tools verwendet wird, verfügen IT-Profis und MSPs über ein umfangreiches Werkzeugset, um sicherzustellen, dass ihre Netzwerke nicht kompromittiert werden.

Und damit haben Sie es. Rüsten Sie sich mit den richtigen Werkzeugen und dem entsprechenden Wissen aus, um Ihre IT-Umgebung effektiv zu schützen. Bleiben Sie dran und verfolgen Sie diesen Bereich für weitere Lösungen im Bereich Unternehmens-IT.

Next Steps

Building an efficient and effective IT team requires a centralized solution that acts as your core service deliver tool. NinjaOne enables IT teams to monitor, manage, secure, and support all their devices, wherever they are, without the need for complex on-premises infrastructure.

Learn more about NinjaOne Remote Script Deployment, check out a live tour, or start your free trial of the NinjaOne platform.

Kategorien:

Das könnte Sie auch interessieren

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