Systemstart-Sicherheit meistern: PowerShell-Skript-Guide zur Prüfung von Autorunsc

Die wichtigsten Erkenntnisse

  • Umfassende Prüfung: Das Skript prüft Startobjekte gründlich und erhöht dadurch die Sicherheit und Leistung des Systems.
  • Automatisierung und Effizienz: Automatisiert den Prozess des Herunterladens und Ausführens von Autorunsc und spart so Zeit im Vergleich zu manuellen Methoden.
  • Anpassbare Parameter: Bietet die Flexibilität, bestimmte Autorun-Elemente wie Dienste, geplante Aufgaben oder Startanwendungen zu konfigurieren.
  • Effiziente Berichterstattung: Gibt die Ergebnisse in ein Aktivitätsprotokoll und optional in ein benutzerdefiniertes Feld zur einfachen Dokumentation und Überprüfung aus.
  • Notwendigkeit von Administratorrechten: Für den vollen Funktionsumfang sind Administratorrechte erforderlich, insbesondere für das Schreiben in benutzerdefinierte Felder.
  • Kompatibilität: Entwickelt für Windows 10, Server 2012 und höher, was eine breite Anwendbarkeit in modernen IT-Umgebungen gewährleistet.
  • Identifizierung von Malware: Hilft bei der Identifizierung verdächtiger Autorun-Elemente, was ein wichtiger Schritt bei der Erkennung und Verhinderung von Malware ist.
  • Regelmäßige Prüfungen werden empfohlen: Es wird empfohlen, das Skript regelmäßig zu verwenden, um die Systemintegrität und -sicherheit aufrechtzuerhalten.
  • Sorgfältige Analyse der Ergebnisse: Betont die Notwendigkeit einer sorgfältigen Überprüfung der Prüfungsergebnisse, um falsch positive Ergebnisse zu vermeiden und die Zuverlässigkeit des Systems zu gewährleisten.
  • Integration mit IT-Management-Tools: Beweist, wie die Integration mit Tools wie NinjaOne die IT-Verwaltung und Sicherheitsstrategien verbessern kann.

Für IT-Expert:innen und Managed Service Provider (MSPs) ist es entscheidend, die Feinheiten von IT-Systemen zu verstehen, insbesondere im Bereich der Sicherheit und des Systemstart-Managements. Die effiziente Überprüfung und Verwaltung von Autorun-Elementen ist ein wesentlicher Bestandteil der Aufrechterhaltung der Systemintegrität und -sicherheit. In diesem Blogbeitrag wird ein PowerShell-Skript vorgestellt, das Autorunsc, ein Sysinternals-Tool, zur Durchführung umfassender Systemstart-Prüfungen verwendet.

Kontext

Das thematisierte Skript dient dazu, Autorunsc mit verschiedenen benutzerdefinierten Parametern auszuführen und die Ergebnisse in ein Aktivitätsprotokoll und möglicherweise in ein benutzerdefiniertes Feld auszugeben. Autorunsc ist ein renommiertes Tool von Sysinternals, das Mark Russinovich entwickelt hat. Es bietet einen detaillierten Einblick in alle Programme und Skripte, die so konfiguriert sind, dass sie während des Systemstarts oder der Benutzeranmeldung ausgeführt werden.

Für IT-Expert:innen und MSPs ist dieses Skript ein wichtiges Asset, da es ihnen ermöglicht, potenziell schädliche oder unnötige Startobjekte schnell zu identifizieren und so die Systemleistung und Sicherheit zu verbessern.

Das Skript zur Prüfung von Autorunsc

#Requires -Version 4

<#
.SYNOPSIS
    Runs Autorunsc with your selected options and outputs the results to the activity log and optionally a WYSIWYG custom field. Please note that there is a limit to the number of results that can be set in Custom Fields or viewed in the Activity Log.
.DESCRIPTION
    Runs Autorunsc with your selected options and outputs the results to the activity log and optionally a WYSIWYG custom field. Please note that there is a limit to the number of results that can be set in Custom Fields or viewed in the Activity Log.
.EXAMPLE
    (No Parameters)
    URL Given, Downloading the file...
    Download Attempt 1
    HKCU:\SOFTWARE\Sysinternals\AutoRuns\EulaAccepted changed from 1 to 1

    Sysinternals Autoruns v14.10 - Autostart program viewer
    Copyright (C) 2002-2023 Mark Russinovich
    Sysinternals - www.sysinternals.com

    WARNING: Script must be elevated in order to write to custom field.
    
    Entry          : C:\Windows\system32\userinit.exe
    Entry Location : HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit
    Image Path     : c:\windows\system32\userinit.exe
    Signer         : (Verified) Microsoft Windows
    MD5            : 9C4C281156040CF01EA35D759092F540

    Entry          : cmd.exe
    Entry Location : HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\AlternateShell
    Image Path     : c:\windows\system32\cmd.exe
    Signer         : (Verified) Microsoft Windows
    MD5            : 8A2122E8162DBEF04694B9C3E0B6CDEE

PARAMETER: -CustomField "ReplaceWithAMultilineCustomField"
    The name of the multiline custom field you would like to save the results to.

PARAMETER: -Startup
    Applications or scripts configured to run automatically after a user logs into their account. This is the default option for Autoruns. 
    E.g. Applications in the 'Startup' folder.

PARAMETER: -Boot
    Programs or commands that are set to execute during the system's boot-up sequence before a user logs in.

PARAMETER: -WinLogon
    Items that are configured to run during the Windows logon process. Often these items are critical to the logon UI.

PARAMETER: -AppInit
    DLLs that are automatically loaded by every process that calls the User32.dll file (anything with a GUI).

PARAMETER: -Explorer
    Plugins or extensions that integrate into the Windows Explorer shell.

PARAMETER: -Sidebar
    Mini applications or gadgets that load into the desktop sidebar in earlier versions of Windows (introduced in Windows Vista).

PARAMETER: -ImageHijacks
    Registry modifications that redirect the execution of specific executable files to a different program.

PARAMETER: -IEAddons
    Browser extensions or toolbars that Internet Explorer will load automatically when it starts.

PARAMETER: -KnownDLLs
    Crucial system DLLs that Windows will load into memory at startup.

PARAMETER: -WMIentries
    Entries related to WMI scripts or providers that are set to execute automatically.

PARAMETER: -WinSockProtocols
    Modules or services meant to load up with the Windows network stack.

PARAMETER: -Codecs
    Software components meant to be used for encoding or decoding digital media streams (often set to run at system startup).

PARAMETER: -PrinterMonitor
    DLL's associated with printer drivers.

PARAMETER: -LSAProviders
    Plugins that integrate with the Local Security Authority subsystem.

PARAMETER: -Services
    Windows Services set to start Automatically.

PARAMETER: -ScheduledTasks
    These are tasks set in Task Scheduler to do something automatically at a specified interval.

PARAMETER: -HideMicrosoftEntries
    Hides Signed Microsoft Entries from the results.

PARAMETER: -DestinationFolder
    By default this script downloads autorunsc to the temp folder.

PARAMETER: -DownloadUrl
    URL to download Autoruns from.

PARAMETER: -SkipSleep
    Skips sleeping prior to downloading autorunsc.
.OUTPUTS
    None
.NOTES
    Minimum OS Architecture Supported: Windows 10, Server 2012
    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()]
    [String]$CustomField,
    [Parameter()]
    [Switch]$Startup = [System.Convert]::ToBoolean($env:checkLogonStartupEntries),
    [Parameter()]
    [Switch]$Boot = [System.Convert]::ToBoolean($env:checkBootEntries),
    [Parameter()]
    [Switch]$WinLogon = [System.Convert]::ToBoolean($env:checkWinlogonEntries),
    [Parameter()]
    [Switch]$AppInit = [System.Convert]::ToBoolean($env:checkAppinitEntries),
    [Parameter()]
    [Switch]$Explorer = [System.Convert]::ToBoolean($env:checkExplorerAddons),
    [Parameter()]
    [Switch]$Sidebar = [System.Convert]::ToBoolean($env:checkSidebarGadgets),
    [Parameter()]
    [Switch]$ImageHijacks = [System.Convert]::ToBoolean($env:checkImageHijacks),
    [Parameter()]
    [Switch]$IEAddons = [System.Convert]::ToBoolean($env:checkInternetExplorerAddons),
    [Parameter()]
    [Switch]$KnownDLLs = [System.Convert]::ToBoolean($env:checkKnownDlls),
    [Parameter()]
    [Switch]$WMIentries = [System.Convert]::ToBoolean($env:checkWmiEntries),
    [Parameter()]
    [Switch]$WinSockProtocols = [System.Convert]::ToBoolean($env:checkWinsockProtocol),
    [Parameter()]
    [Switch]$Codecs = [System.Convert]::ToBoolean($env:checkCodecs),
    [Parameter()]
    [Switch]$PrinterMonitor = [System.Convert]::ToBoolean($env:checkPrinterMonitorDlls),
    [Parameter()]
    [Switch]$LSAProviders = [System.Convert]::ToBoolean($env:checkLsaSecurityProviders),
    [Parameter()]
    [Switch]$Services = [System.Convert]::ToBoolean($env:checkAutostartServices),
    [Parameter()]
    [Switch]$ScheduledTasks = [System.Convert]::ToBoolean($env:checkScheduledTasks),
    [Parameter()]
    [Switch]$HideMicrosoftEntries = [System.Convert]::ToBoolean($env:hideMicrosoftEntries),
    [Parameter()]
    [String]$DestinationFolder = "$env:Temp",
    [Parameter()]
    [String]$DownloadUrl = "https://download.sysinternals.com/files/Autoruns.zip",
    [Parameter()]
    [Switch]$SkipSleep = [System.Convert]::ToBoolean($env:skipSleep)
)

begin {

    # If Script Forms are used replace the parameters
    if ($env:destinationFolder -and $env:DestinationFolder -notlike "null") { $DestinationFolder = $env:destinationFolder }
    if ($env:downloadUrl -and $env:downloadUrl -notlike "null") { $DownloadUrl = $env:downloadUrl }
    if ($env:customFieldName -and $env:customFieldName -notlike "null") { $CustomField = $env:customFieldName }

    if ($PSVersionTable.PSVersion.Major -lt 5) {
        function Expand-Archive {
            [CmdletBinding()]
            param(
                [Parameter()]
                [String]$Path,
                [Parameter()]
                [String]$DestinationPath,
                [Parameter()]
                [Switch]$Force
            )
            begin {
                Add-Type -assembly "System.IO.Compression.FileSystem"
            }
            process {
                if ($Force -and (Test-Path $DestinationPath)) {
                    $ZipFile = [System.IO.Compression.ZipFile]::OpenRead($Path)

                    $ZipFile.Entries | ForEach-Object {
                        $Destination = [System.IO.Path]::Combine($DestinationPath, $_.FullName)
                        $DestinationDir = [System.IO.Path]::GetDirectoryName($Destination)
                        if (-not (Test-Path $DestinationDir)) {
                            New-Item -ItemType Directory -Path $DestinationDir -Force
                        }
                        [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $Destination, $True)
                    }
                    $ZipFile.Dispose()
                }
                else {
                    [System.IO.Compression.ZipFile]::ExtractToDirectory($Path, $DestinationPath)
                }
            }
        }
    }

    # Handy download function
    function Invoke-Download {
        param(
            [Parameter()]
            [String]$URL,
            [Parameter()]
            [String]$Path,
            [Parameter()]
            [Switch]$SkipSleep
        )

        Write-Host "URL Given, Downloading the file..."

        $SupportedTLSversions = [enum]::GetValues('Net.SecurityProtocolType')
        if ( ($SupportedTLSversions -contains 'Tls13') -and ($SupportedTLSversions -contains 'Tls12') ) {
            [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol::Tls13 -bor [System.Net.SecurityProtocolType]::Tls12
        }
        elseif ( $SupportedTLSversions -contains 'Tls12' ) {
            [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
        }
        else {
            # Not everything requires TLS 1.2, but we'll try anyways.
            Write-Warning "TLS 1.2 and or TLS 1.3 isn't supported on this system. This download may fail!"
            if ($PSVersionTable.PSVersion.Major -lt 3) {
                Write-Warning "PowerShell 2 / .NET 2.0 doesn't support TLS 1.2."
            }
        }

        $i = 1
        While ($i -lt 4) {
            if (-not ($SkipSleep)) {
                $SleepTime = Get-Random -Minimum 3 -Maximum 60
                Start-Sleep -Seconds $SleepTime
            }

            Write-Host "Download Attempt $i"

            try {
                $WebClient = New-Object System.Net.WebClient
                $WebClient.DownloadFile($URL, $Path)
            }
            catch {
                Write-Warning "An error has occurred while downloading!"
            }

            $File = Test-Path -Path $Path -ErrorAction SilentlyContinue
            if ($File) {
                $i = 4
            }
            else {
                $i++
            }
        }

        if (-not $File) { 
            Write-Error -Message "File failed to download!" -Category DeviceError -Exception (New-Object System.Exception)
            Exit 1 
        }
    }

    # Need to set Regkey to accept EULA
    function Set-RegKey {
        param (
            $Path,
            $Name,
            $Value,
            [ValidateSet("DWord", "QWord", "String", "ExpandedString", "Binary", "MultiString", "Unknown")]
            $PropertyType = "DWord"
        )
        if (-not $(Test-Path -Path $Path)) {
            # Check if path does not exist and create the path
            New-Item -Path $Path -Force | Out-Null
        }
        if ((Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue)) {
            # Update property and print out what it was changed from and changed to
            $CurrentValue = (Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue).$Name
            try {
                Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false -ErrorAction Stop | Out-Null
            }
            catch {
                Write-Error -Message "[Error] Unable to Set registry key for $Name please see below error!" -Category DeviceError -Exception (New-Object System.Exception)
                Write-Error $_
                exit 1
            }
            Write-Host "$Path\$Name changed from $CurrentValue to $($(Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue).$Name)"
        }
        else {
            # Create property with value
            try {
                New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force -Confirm:$false -ErrorAction Stop | Out-Null
            }
            catch {
                Write-Error -Message "[Error] Unable to Set registry key for $Name please see below error!" -Category DeviceError -Exception (New-Object System.Exception)
                Write-Error $_
                exit 1
            }
            Write-Host "Set $Path\$Name to $($(Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue).$Name)"
        }
    }

    function Set-NinjaProperty {
        [CmdletBinding()]
        Param(
            [Parameter(Mandatory = $True)]
            [String]$Name,
            [Parameter()]
            [String]$Type,
            [Parameter(Mandatory = $True, ValueFromPipeline = $True)]
            $Value,
            [Parameter()]
            [String]$DocumentName
        )

        $Characters = $Value | Measure-Object -Character | Select-Object -ExpandProperty Characters
        if($Characters -ge 10000){
            throw [System.ArgumentOutOfRangeException]::New("Character limit exceeded, value is greater than 10,000 characters.")
        }
    
        # If we're requested to set the field value for a Ninja document we'll specify it here.
        $DocumentationParams = @{}
        if ($DocumentName) { $DocumentationParams["DocumentName"] = $DocumentName }
    
        # This is a list of valid fields that can be set. If no type is given, it will be assumed that the input doesn't need to be changed.
        $ValidFields = "Attachment", "Checkbox", "Date", "Date or Date Time", "Decimal", "Dropdown", "Email", "Integer", "IP Address", "MultiLine", "MultiSelect", "Phone", "Secure", "Text", "Time", "URL", "WYSIWYG"
        if ($Type -and $ValidFields -notcontains $Type) { Write-Warning "$Type is an invalid type! Please check here for valid types. https://ninjarmm.zendesk.com/hc/en-us/articles/16973443979789-Command-Line-Interface-CLI-Supported-Fields-and-Functionality" }
    
        # The field below requires additional information to be set
        $NeedsOptions = "Dropdown"
        if ($DocumentName) {
            if ($NeedsOptions -contains $Type) {
                # We'll redirect the error output to the success stream to make it easier to error out if nothing was found or something else went wrong.
                $NinjaPropertyOptions = Ninja-Property-Docs-Options -AttributeName $Name @DocumentationParams 2>&1
            }
        }
        else {
            if ($NeedsOptions -contains $Type) {
                $NinjaPropertyOptions = Ninja-Property-Options -Name $Name 2>&1
            }
        }
    
        # If an error is received it will have an exception property, the function will exit with that error information.
        if ($NinjaPropertyOptions.Exception) { throw $NinjaPropertyOptions }
    
        # The below type's require values not typically given in order to be set. The below code will convert whatever we're given into a format ninjarmm-cli supports.
        switch ($Type) {
            "Checkbox" {
                # While it's highly likely we were given a value like "True" or a boolean datatype it's better to be safe than sorry.
                $NinjaValue = [System.Convert]::ToBoolean($Value)
            }
            "Date or Date Time" {
                # Ninjarmm-cli expects the GUID of the option to be selected. Therefore, the given value will be matched with a GUID.
                $Date = (Get-Date $Value).ToUniversalTime()
                $TimeSpan = New-TimeSpan (Get-Date "1970-01-01 00:00:00") $Date
                $NinjaValue = $TimeSpan.TotalSeconds
            }
            "Dropdown" {
                # Ninjarmm-cli is expecting the guid of the option we're trying to select. So we'll match up the value we were given with a guid.
                $Options = $NinjaPropertyOptions -replace '=', ',' | ConvertFrom-Csv -Header "GUID", "Name"
                $Selection = $Options | Where-Object { $_.Name -eq $Value } | Select-Object -ExpandProperty GUID
    
                if (-not $Selection) {
                    throw [System.ArgumentOutOfRangeException]::New("Value is not present in dropdown")
                }
    
                $NinjaValue = $Selection
            }
            default {
                # All the other types shouldn't require additional work on the input.
                $NinjaValue = $Value
            }
        }
    
        # We'll need to set the field differently depending on if its a field in a Ninja Document or not.
        if ($DocumentName) {
            $CustomField = Ninja-Property-Docs-Set -AttributeName $Name -AttributeValue $NinjaValue @DocumentationParams 2>&1
        }
        else {
            $CustomField = Ninja-Property-Set -Name $Name -Value $NinjaValue 2>&1
        }
    
        if ($CustomField.Exception) {
            throw $CustomField
        }
    }

    # Test for elevation
    function Test-IsElevated {
        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
        $p = New-Object System.Security.Principal.WindowsPrincipal($id)
        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
    }

    $ExitCode = 0
}
process {

    # Take the script parameters and translate them into Autoruns options.
    if ($Startup) { $AutorunOptions = "l" }
    if ($Boot) { $AutorunOptions = "$($AutorunOptions)b" }
    if ($Winlogon) { $AutorunOptions = "$($AutorunOptions)w" }
    if ($AppInit) { $AutorunOptions = "$($AutorunOptions)d" }
    if ($Explorer) { $AutorunOptions = "$($AutorunOptions)e" }
    if ($Sidebar) { $AutorunOptions = "$($AutorunOptions)g" }
    if ($ImageHijacks) { $AutorunOptions = "$($AutorunOptions)h" }
    if ($IEAddons) { $AutorunOptions = "$($AutorunOptions)i" }
    if ($KnownDLLs) { $AutorunOptions = "$($AutorunOptions)k" }
    if ($WMIentries) { $AutorunOptions = "$($AutorunOptions)m" }
    if ($WinSockProtocols) { $AutorunOptions = "$($AutorunOptions)n" }
    if ($Codecs) { $AutorunOptions = "$($AutorunOptions)o" }
    if ($PrinterMonitor) { $AutorunOptions = "$($AutorunOptions)p" }
    if ($LSAProviders) { $AutorunOptions = "$($AutorunOptions)r" }
    if ($Services) { $AutorunOptions = "$($AutorunOptions)s" }
    if ($ScheduledTasks) { $AutorunOptions = "$($AutorunOptions)t" }

    if (-not $AutorunOptions){
        Write-Error -Message "No Autoruns options selected. Please at least select one option to search for autostart entries." -Category InvalidArgument -Exception (New-Object System.ArgumentNullException)
        exit 1
    }

    # Download the file and unzip its contents
    $DownloadArguments = @{
        URL  = $DownloadUrl
        Path = "$DestinationFolder\Autoruns.zip"
    }
    if ($SkipSleep) { $DownloadArguments["SkipSleep"] = $true }

    # Download and unzip
    Invoke-Download @DownloadArguments
    Expand-Archive -Path "$DestinationFolder\Autoruns.zip" -DestinationPath "$DestinationFolder\Autoruns" -Force

    if (-not (Test-Path "$DestinationFolder\Autoruns\autorunsc64.exe" -ErrorAction SilentlyContinue)) {
        Write-Error -Message "Failed to unzip Autoruns" -Category DeviceError -Exception (New-Object System.Exception)
        exit 1
    }

    # Now that we have the options create an argument list using those options
    $ArgumentList = New-Object System.Collections.Generic.List[string]
    $ArgumentList.Add("-a $AutorunOptions")
    $ArgumentList.Add("-h")
    $ArgumentList.Add("-c")
    $ArgumentList.Add("-s")
    if ($HideMicrosoftEntries) { $ArgumentList.Add("-m") }

    # Accept EULA
    Set-RegKey -Path "HKCU:\SOFTWARE\Sysinternals\AutoRuns" -Name "EulaAccepted" -Value 1

    # Run autoruns and store the results as a csv and then import the results into powershell
    Start-Process "$DestinationFolder\Autoruns\autorunsc64.exe" -ArgumentList $ArgumentList -NoNewWindow -RedirectStandardOutput "$DestinationFolder\Autoruns\autorunsc.csv" -Wait
    $AutorunResults = Import-Csv "$DestinationFolder\Autoruns\autorunsc.csv" | Where-Object { $_.Entry } | Sort-Object Entry | Select-Object Entry, "Entry Location", "Image Path", Signer, MD5

    if (-not ($AutorunResults)) {
        Write-Error -Message "No startup entries found. Is Autorunsc being blocked?" -Category InvalidResult -Exception (New-Object System.ApplicationException)
        $ExitCode = 1
    }

    # Set the custom field with the Autoruns results.
    if ($CustomField) {
        if ($PSVersionTable.PSVersion.Major -lt 3) {
            Write-Warning "Ninjarmm-cli does not support setting custom fields using PowerShell 2.0"
            $ExitCode = 1
        }
        
        if ( -not (Test-IsElevated)) {
            Write-Warning "Script must be elevated in order to write to custom field."
            $ExitCode = 1
        }

        try {
            Write-Host "Attempting to set Custom Field '$CustomField'."
            $htmlTable = $AutorunResults | ConvertTo-HTML -Fragment
            Set-NinjaProperty -Name $CustomField -Value $htmlTable
            Write-Host "Successfully set Custom Field '$CustomField'!"
        }
        catch {
            $_
            $ExitCode = 1
        }
    }

    # Clean up our leftover files.
    Remove-Item "$DestinationFolder\Autoruns" -Recurse -Force
    Remove-Item "$DestinationFolder\Autoruns.zip" -Force

    # Output results into activity log. Using Format-List due to size of table.
    $AutorunResults | Sort-Object Entry | Format-List

    exit $ExitCode
}
end {
    
    
    
}

 

Greifen Sie auf über 300 Skripte im NinjaOne Dojo zu.

Zugang erhalten

Detaillierte Aufschlüsselung

Das Skript beginnt mit der Einrichtung von Parametern, die es Benutzer:innen ermöglichen, verschiedene zu überprüfende Autorun-Einträge anzugeben, zum Beispiel Startanwendungen, ausführbare Boot-Dateien und geplante Aufgaben. Es lädt das Autorunsc-Tool herunter, führt es mit den gewählten Parametern aus und sammelt die Ausgabe.

Die wichtigsten Schritte des Skripts:

  • Initialisierung der Parameter: Anwender:innen können die Art der zu prüfenden Autorun-Elemente auswählen, wie etwa Startobjekte, geplante Aufgaben oder Dienste.
  • Herunterladen von Autorunsc: Das Skript lädt automatisch Autorunsc von Sysinternals herunter.
  • Ausführung und Handhabung der Ausgabe: Autorunsc wird mit den angegebenen Parametern ausgeführt, und die Ausgabe wird in ein lesbares Format formatiert.
  • Schreiben in ein benutzerdefiniertes Feld: Optional lassen sich die Ergebnisse in einem benutzerdefinierten Feld speichern, sofern das Skript mit erhöhten Rechten ausgeführt wird.
  • Bereinigung: Nach der Ausführung bereinigt das Skript die heruntergeladenen und temporär erzeugten Dateien.

Mögliche Anwendungsfälle

Stellen Sie sich vor, ein IT-Experte hat den Verdacht, dass in den Systemen seines Unternehmens beim Start nicht autorisierte oder schädliche Software ausgeführt wird. Wenn er dieses Skript ausführt, kann er schnell alle Startobjekte überprüfen und unerwünschte oder verdächtige Anwendungen identifizieren, was die Sicherheit und Leistung des Systems erhöht.

Vergleiche

Herkömmliche Methoden zur Überprüfung von Startobjekten beinhalten oft die manuelle Überprüfung verschiedener Systemorte oder die Verwendung separater Tools für verschiedene Starttypen. Dieses Skript vereinfacht und konsolidiert den Prozess, indem es ein einziges Tool (Autorunsc) in Anspruch nimmt, um eine umfassende Reihe von Autorun-Elementen zu überprüfen. Im Vergleich zu manuellen Methoden spart dieses Skript Zeit und verringert die Wahrscheinlichkeit, dass kritische Autorun-Elemente übersehen werden.

FAQs

Q1: Ist dieses Skript für alle Windows-Versionen geeignet?
A1: Das Skript ist für Windows 10, Server 2012 und höher konzipiert.

Q2: Benötige ich Administratorrechte, um dieses Skript auszuführen?
A2: Ja, für bestimmte Vorgänge, wie das Schreiben in ein benutzerdefiniertes Feld, sind Administratorrechte erforderlich.

Q3: Kann dieses Skript Malware erkennen?
A3: Es kann zwar nicht autorisierte oder unbekannte Startobjekte identifizieren, doch ist eine weitere Analyse erforderlich, um festzustellen, ob es sich um Malware handelt.

Folgen

Die Verwendung dieses Skripts bei der Überprüfung von Startobjekten ist für die IT-Sicherheit bedeutend. Die Identifizierung und Verwaltung von Autorun-Elementen kann die Ausführung von Malware beim Start verhindern und die Systemleistung verbessern. Es ist jedoch wichtig, die Prüfergebnisse sorgfältig zu analysieren, um falsch positive Ergebnisse zu vermeiden und sicherzustellen, dass legitime Software nicht versehentlich blockiert wird.

Empfehlungen

Zu den Best Practices bei der Verwendung dieses Skripts gehören:

  • Regelmäßige Audits zur Aufrechterhaltung der Systemintegrität.
  • Führen Sie das Skript mit Administratorrechten aus, um die volle Funktionalität zu erhalten.
  • Analysieren Sie sorgfältig die Prüfergebnisse, um unberechtigte oder unnötige Autorun-Elemente zu identifizieren und entsprechende Maßnahmen zu ergreifen.

Abschließende Überlegungen

Im Rahmen einer effizienten IT-Systemverwaltung können Tools wie NinjaOne in Kombination mit leistungsstarken Skripten wie dem PowerShell-Skript zur Prüfung von Autorunsc die Fähigkeit eines IT-Experten, den Systemzustand und die Sicherheit aufrechtzuerhalten, erheblich verbessern. Die umfassende IT-Management-Suite von NinjaOne, integriert mit solchen Skripten, bietet eine robuste Lösung für die Überwachung, Verwaltung und Sicherung von IT-Infrastrukturen.

Next Steps

Building an efficient and effective IT team requires a centralized solution that acts as your core service delivery 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

×

Sehen Sie NinjaOne in Aktion!

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

NinjaOne Allgemeine Geschäftsbedingungen für Skripte

Indem Sie unten auf die Schaltfläche „Ich akzeptiere“ klicken, erklären Sie Ihr Einverständnis mit den folgenden rechtlichen Bedingungen sowie mit unseren Nutzungsbedingungen:

  • Eigentumsrechte: NinjaOne besitzt und wird weiterhin alle Rechte, Titel und Interessen an dem Skript (einschließlich des Urheberrechts) behalten. NinjaOne gewährt Ihnen eine eingeschränkte Lizenz zur Nutzung des Skripts in Übereinstimmung mit diesen rechtlichen Bedingungen.
  • Einschränkung der Nutzung: Sie dürfen das Skript nur für Ihre legitimen persönlichen oder internen Geschäftszwecke verwenden und es nicht an Dritte weitergeben.
  • Verbot der Wiederveröffentlichung: Sie sind unter keinen Umständen berechtigt, das Skript in einer Skriptbibliothek, die einem anderen Softwareanbieter gehört oder von diesem kontrolliert wird, erneut zu veröffentlichen.
  • Gewährleistungsausschluss: Das Skript wird „wie gesehen“ und „wie verfügbar“ bereitgestellt, ohne jegliche Garantie. NinjaOne gibt keine Versprechen oder Garantien, dass das Skript frei von Fehlern ist oder dass es Ihre speziellen Bedürfnisse oder Erwartungen erfüllt.
  • Risikoübernahme: Die Verwendung des Skripts erfolgt auf eigene Gefahr. Sie erkennen an, dass die Nutzung des Skripts mit bestimmten Risiken verbunden ist, und Sie verstehen und übernehmen jedes dieser Risiken.
  • Verzicht und Freigabe: Sie machen NinjaOne nicht für nachteilige oder unbeabsichtigte Folgen verantwortlich, die sich aus Ihrer Nutzung des Skripts ergeben, und Sie verzichten auf alle gesetzlichen oder billigkeitsrechtlichen Rechte oder Rechtsmittel, die Sie gegen NinjaOne im Zusammenhang mit Ihrer Nutzung des Skripts haben könnten.
  • EULA: Wenn Sie ein NinjaOne-Kunde sind, unterliegt Ihre Nutzung des Skripts dem für Sie geltenden Endbenutzer-Lizenzvertrag (EULA).