{"id":383257,"date":"2024-11-15T09:59:42","date_gmt":"2024-11-15T09:59:42","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=383257"},"modified":"2024-11-15T10:02:24","modified_gmt":"2024-11-15T10:02:24","slug":"verifizierung-von-datei-hash-werten-mit-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/de\/script-hub\/verifizierung-von-datei-hash-werten-mit-powershell\/","title":{"rendered":"IT-Sicherheits-Guide: Die \u00dcberpr\u00fcfung von Datei-Hash-Werten mit PowerShell"},"content":{"rendered":"<p>In der heutigen IT-Welt ist die Gew\u00e4hrleistung von Datenintegrit\u00e4t und -sicherheit ausschlaggebend. Eine wirksame Methode zur \u00dcberpr\u00fcfung der Integrit\u00e4t von Dateien ist die Verwendung von Hash-Werten. Ein Hash-Wert wirkt wie ein digitaler Fingerabdruck f\u00fcr Dateien, mit dem IT-Experten \u00fcberpr\u00fcfen k\u00f6nnen, ob Dateien manipuliert oder besch\u00e4digt wurden. In diesem Blogbeitrag wird ein PowerShell-Skript vorgestellt, das f\u00fcr die Suche nach Dateien mit bestimmten Hash-Werten entwickelt wurde und somit ein unsch\u00e4tzbares Tool f\u00fcr IT-Experten und <a href=\"https:\/\/www.ninjaone.com\/de\/was-ist-ein-msp\" target=\"_blank\" rel=\"noopener\">Managed Service Provider (MSPs)<\/a> darstellt. Erfahren Sie, wie sich die Verifizierung von Datei-Hash-Werten mit PowerShell automatisieren l\u00e4sst.<\/p>\n<h2>Kontext<\/h2>\n<p>Das mitgelieferte PowerShell-Skript wurde entwickelt, um Benutzer:innen zu benachrichtigen, wenn eine Datei mit einem bestimmten Hash und einer bestimmten Erweiterung in einem angegebenen Verzeichnis und seinen Unterverzeichnissen gefunden wird. Das Hashing von Dateien ist in der IT-Branche eine g\u00e4ngige Praxis, um die Integrit\u00e4t von Dateien zu \u00fcberpr\u00fcfen und unbefugte \u00c4nderungen zu erkennen. Dieses Skript vereinfacht und automatisiert den Prozess und erleichtert es IT-Experten, die Sicherheit und Integrit\u00e4t ihrer Systeme zu gew\u00e4hrleisten.<\/p>\n<h2>Das Skript zur Verifizierung von Datei-Hash-Werten<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Alerts if a file with the extension and specified hash is found in the given search directory or subdirectories. Warning: Hashing large files may impact performance.\r\n.DESCRIPTION\r\n    Alerts if a file with the extension and specified hash is found in the given search directory or subdirectories. Warning: Hashing large files may impact performance.\r\n.EXAMPLE\r\n    -Hash \"F55A61A82F4F5943F86565E1FA2CCB4F\" -SearchPath \"C:\" -FileType \".ico\" -CustomField \"multiline\"\r\n    WARNING: Backslash missing from the search path. Changing it to C:\\.\r\n    WARNING: File with MD5 hash of F55A61A82F4F5943F86565E1FA2CCB4F found!\r\n\r\n    File Name         Path                                                                                    \r\n    ---------         ----                                                                                    \r\n    zoo_ecosystem.ico C:\\Users\\Administrator\\Desktop\\Find-FileHash\\Test Folder 1\\zoo_ecosystem.ico            \r\n    zoo_ecosystem.ico C:\\Users\\Administrator\\Desktop\\Find-FileHash\\TestFolder1\\Test Folder 1\\zoo_ecosystem.ico\r\n    zoo_ecosystem.ico C:\\Users\\Administrator\\Desktop\\Find-FileHash\\TestFolder2\\Test Folder 1\\zoo_ecosystem.ico\r\n\r\n    Attempting to set Custom Field 'multiline'.\r\n    Successfully set Custom Field 'multiline'!\r\n\r\nPARAMETER: -Hash \"REPLACEMEWITHAVALIDHASH\"\r\n    Files with this hash should cause the alert to trigger.\r\n\r\nPARAMETER: -Algorithm \"MD5\"\r\n    Hashing algorithm used for the above hash.\r\n\r\nPARAMETER: -SearchPath \"C:\\ReplaceMeWithAValidSearchPath\"\r\n   Specifies one or more starting directories for the search, separated by commas. The search will recursively include all subdirectories from these starting points.\r\n\r\nPARAMETER: -Timeout \"15\"\r\n    Once this timeout is reached, the script will stop searching for files that match your given hash.\r\n\r\nPARAMETER: -FileType \".exe\"\r\n    Specifies the file extension to filter the search. Only files with this extension will be analyzed for a hash match. Example: '.exe'\r\n\r\nPARAMETER: -CustomField \"NameOfMultiLineCustomField\"\r\n    Specifies the name of an optional multiline custom field where results can be sent. \r\n\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows Server 2016\r\n    Release Notes: 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()]\r\n    [String]$Hash,\r\n    [Parameter()]\r\n    [String]$SearchPath = \"C:\\Windows\",\r\n    [Parameter()]\r\n    [String]$FileType,\r\n    [Parameter()]\r\n    [Int]$Timeout = 15,\r\n    [Parameter()]\r\n    [String]$Algorithm = \"MD5\",\r\n    [Parameter()]\r\n    [String]$CustomField\r\n)\r\n\r\nbegin {\r\n    # Set parameters using dynamic script variables.\r\n    if ($env:hash -and $env:hash -notlike \"null\") { $Hash = $env:hash }\r\n    if ($env:hashType -and $env:hashType -notlike \"null\") { $Algorithm = $env:hashType }\r\n    if ($env:searchPath -and $env:searchPath -notlike \"null\") { $SearchPath = $env:searchPath }\r\n    if ($env:timeoutInMinutes -and $env:timeoutInMinutes -notlike \"null\") { $Timeout = $env:timeoutInMinutes }\r\n    if ($env:fileExtensionToSearchFor -and $env:fileExtensionToSearchFor -notlike \"null\") { $FileType = $env:fileExtensionToSearchFor }\r\n    if ($env:customFieldName -and $env:customFieldName -notlike \"null\") { $CustomField = $env:customFieldName }\r\n\r\n    # If given a comma-separated list, split the paths.\r\n    $PathsToSearch = New-Object System.Collections.Generic.List[String]\r\n    if ($SearchPath -match \",\") {\r\n        $SearchPath -split \",\" | ForEach-Object { $PathsToSearch.Add($_.Trim()) }\r\n    }\r\n    else {\r\n        $PathsToSearch.Add($SearchPath)\r\n    }\r\n\r\n    $ReplacementPaths = New-Object System.Collections.Generic.List[Object]\r\n    $PathsToRemove = New-Object System.Collections.Generic.List[String]\r\n\r\n    # If given a drive without the backslash add it in.\r\n    $PathsToSearch | ForEach-Object {\r\n        if ($_ -notmatch '^[A-Z]:\\\\$' -and $_ -match '^[A-Z]:$') {\r\n            $NewPath = \"$_\\\"\r\n            $ReplacementPaths.Add(\r\n                [PSCustomObject]@{\r\n                    Index   = $PathsToSearch.IndexOf(\"$_\")\r\n                    NewPath = $NewPath\r\n                }\r\n            )\r\n                \r\n            Write-Warning \"Backslash missing from the search path. Changing it to $NewPath.\"\r\n        }\r\n    }\r\n\r\n    # Apply replacements\r\n    $ReplacementPaths | ForEach-Object {\r\n        $PathsToSearch[$_.index] = $_.NewPath \r\n    }\r\n\r\n    # Check if the search path is valid.\r\n    $PathsToSearch | ForEach-Object {\r\n        if (-not (Test-Path $_)) {\r\n            Write-Host -Object \"[Error] $_ does not exist!\"\r\n            $PathsToRemove.Add($_)\r\n            $ExitCode = 1\r\n        }\r\n    }\r\n\r\n    $PathsToRemove | ForEach-Object {\r\n        $PathsToSearch.Remove($_) | Out-Null\r\n    }\r\n\r\n\r\n    # Error out if no valid paths to search.\r\n    if ($PathsToSearch.Count -eq 0) {\r\n        Write-Host \"[Error] No valid paths to search!\"\r\n        exit 1\r\n    }\r\n\r\n    # A file extension is required.\r\n    if (-not $FileType) {\r\n        Write-Host -Object \"[Error] File Type is required!\"\r\n        exit 1\r\n    }\r\n\r\n    # If we were given the extension without the . we'll add it back in\r\n    if ($FileType -notmatch '^\\.') {\r\n        $FileType = \".$FileType\"\r\n        Write-Warning -Message \"Extension missing changing filetype to $FileType.\"\r\n    }\r\n\r\n    # The timeout has to be between 1 and 120\r\n    if ($Timeout -lt 1 -or $Timeout -gt 120) {\r\n        Write-Host \"[Error] Invalid timeout given of $Timeout minutes. Please enter a value between 1 and 120.\"\r\n        exit 1\r\n    }\r\n\r\n    # PowerShell 5.1 supports more algorithms than this, however PowerShell 7 does not.\r\n    $ValidAlgorithms = \"SHA1\", \"SHA256\", \"SHA384\", \"SHA512\", \"MD5\"\r\n    if ($ValidAlgorithms -notcontains $Algorithm) {\r\n        Write-Host \"[Error] Invalid Algorithm selected. Only SHA1, SHA256, SHA384, SHA512 and MD5 are supported.\"\r\n        exit 1\r\n    }\r\n\r\n    # Helper function to make it easier to set custom fields.\r\n    function Set-NinjaProperty {\r\n        [CmdletBinding()]\r\n        Param(\r\n            [Parameter(Mandatory = $True)]\r\n            [String]$Name,\r\n            [Parameter()]\r\n            [String]$Type,\r\n            [Parameter(Mandatory = $True, ValueFromPipeline = $True)]\r\n            $Value,\r\n            [Parameter()]\r\n            [String]$DocumentName\r\n        )\r\n    \r\n        $Characters = $Value | Measure-Object -Character | Select-Object -ExpandProperty Characters\r\n        if ($Characters -ge 10000) {\r\n            throw [System.ArgumentOutOfRangeException]::New(\"Character limit exceeded, value is greater than 10,000 characters.\")\r\n        }\r\n        \r\n        # If we're requested to set the field value for a Ninja document we'll specify it here.\r\n        $DocumentationParams = @{}\r\n        if ($DocumentName) { $DocumentationParams[\"DocumentName\"] = $DocumentName }\r\n        \r\n        # 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.\r\n        $ValidFields = \"Attachment\", \"Checkbox\", \"Date\", \"Date or Date Time\", \"Decimal\", \"Dropdown\", \"Email\", \"Integer\", \"IP Address\", \"MultiLine\", \"MultiSelect\", \"Phone\", \"Secure\", \"Text\", \"Time\", \"URL\", \"WYSIWYG\"\r\n        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\" }\r\n        \r\n        # The field below requires additional information to be set\r\n        $NeedsOptions = \"Dropdown\"\r\n        if ($DocumentName) {\r\n            if ($NeedsOptions -contains $Type) {\r\n                # 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.\r\n                $NinjaPropertyOptions = Ninja-Property-Docs-Options -AttributeName $Name @DocumentationParams 2&gt;&amp;1\r\n            }\r\n        }\r\n        else {\r\n            if ($NeedsOptions -contains $Type) {\r\n                $NinjaPropertyOptions = Ninja-Property-Options -Name $Name 2&gt;&amp;1\r\n            }\r\n        }\r\n        \r\n        # If an error is received it will have an exception property, the function will exit with that error information.\r\n        if ($NinjaPropertyOptions.Exception) { throw $NinjaPropertyOptions }\r\n        \r\n        # 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.\r\n        switch ($Type) {\r\n            \"Checkbox\" {\r\n                # While it's highly likely we were given a value like \"True\" or a boolean datatype it's better to be safe than sorry.\r\n                $NinjaValue = [System.Convert]::ToBoolean($Value)\r\n            }\r\n            \"Date or Date Time\" {\r\n                # Ninjarmm-cli expects the  Date-Time to be in Unix Epoch time so we'll convert it here.\r\n                $Date = (Get-Date $Value).ToUniversalTime()\r\n                $TimeSpan = New-TimeSpan (Get-Date \"1970-01-01 00:00:00\") $Date\r\n                $NinjaValue = $TimeSpan.TotalSeconds\r\n            }\r\n            \"Dropdown\" {\r\n                # 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.\r\n                $Options = $NinjaPropertyOptions -replace '=', ',' | ConvertFrom-Csv -Header \"GUID\", \"Name\"\r\n                $Selection = $Options | Where-Object { $_.Name -eq $Value } | Select-Object -ExpandProperty GUID\r\n        \r\n                if (-not $Selection) {\r\n                    throw [System.ArgumentOutOfRangeException]::New(\"Value is not present in dropdown\")\r\n                }\r\n        \r\n                $NinjaValue = $Selection\r\n            }\r\n            default {\r\n                # All the other types shouldn't require additional work on the input.\r\n                $NinjaValue = $Value\r\n            }\r\n        }\r\n        \r\n        # We'll need to set the field differently depending on if its a field in a Ninja Document or not.\r\n        if ($DocumentName) {\r\n            $CustomField = Ninja-Property-Docs-Set -AttributeName $Name -AttributeValue $NinjaValue @DocumentationParams 2&gt;&amp;1\r\n        }\r\n        else {\r\n            $CustomField = Ninja-Property-Set -Name $Name -Value $NinjaValue 2&gt;&amp;1\r\n        }\r\n        \r\n        if ($CustomField.Exception) {\r\n            throw $CustomField\r\n        }\r\n    }\r\n\r\n    # Test for local administrator rights\r\n    function Test-IsElevated {\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n        $p = New-Object System.Security.Principal.WindowsPrincipal($id)\r\n        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)\r\n    }\r\n\r\n    $ExitCode = 0\r\n}\r\nprocess {\r\n    if (-not (Test-IsElevated)) {\r\n        Write-Host -Object \"[Error] Access Denied. Please run with Administrator privileges.\"\r\n        exit 1\r\n    }\r\n\r\n    # If we're given a file instead of a folder, we'll check if it matches anyways.\r\n    $PathsToSearch | ForEach-Object {\r\n        if (-not (Get-Item $_).PSIsContainer) {\r\n            Write-Warning \"The search path you gave is actually a file not a folder. Checking the hash of the file...\"\r\n        }\r\n    }\r\n    \r\n    $HashJobs = New-Object System.Collections.Generic.List[object]\r\n    $MatchingFiles = New-Object System.Collections.Generic.List[object]\r\n    $CustomFieldValue = New-Object System.Collections.Generic.List[string]\r\n\r\n    # We'll use a PowerShell job so that we can timeout appropriately.\r\n    $PathsToSearch | ForEach-Object {\r\n        $HashJobs.Add(\r\n            (\r\n                Start-Job -ScriptBlock {\r\n                    param($SearchPath, $FileType, $Algorithm, $Hash)\r\n                    $Files = Get-ChildItem -Path $SearchPath -Filter \"*$FileType\" -File -Recurse\r\n                    $Files | ForEach-Object {\r\n                        $CurrentHash = Get-FileHash -Path $_.FullName -Algorithm $Algorithm\r\n                        if ($CurrentHash.Hash -match $Hash) { $_.FullName }\r\n                    }\r\n                } -ArgumentList $_, $FileType, $Algorithm, $Hash\r\n            )\r\n        )\r\n    }\r\n\r\n    $TimeoutInSeconds = $Timeout * 60\r\n    $StartTime = Get-Date\r\n\r\n    # Wait for all jobs to complete or timeout\r\n    foreach ($HashJob in $HashJobs) {\r\n        # Calculate the remaining time\r\n        $TimeElapsed = (Get-Date) - $StartTime\r\n        $RemainingTime = $TimeoutInSeconds - $TimeElapsed.TotalSeconds\r\n    \r\n        # If there is no remaining time, break the loop\r\n        if ($RemainingTime -le 0) {\r\n            break\r\n        }\r\n    \r\n        # Wait for the current job with the remaining time as the timeout\r\n        $HashJob | Wait-Job -Timeout $RemainingTime | Out-Null\r\n    }\r\n\r\n    # If we failed to complete the job, we'll output a warning.\r\n    $IncompleteJobs = $HashJobs | Get-Job | Where-Object { $_.State -eq \"Running\" }\r\n    if ($IncompleteJobs) {\r\n        Write-Host \"[Error] The timeout period of $Timeout minutes has been reached, but some files still require a hash check!\"\r\n        $CustomFieldValue.Add(\"[Error] The timeout period of $Timeout minutes has been reached, but some files still require a hash check!\")\r\n        $ExitCode = 1\r\n    }\r\n\r\n    # Receive the data from the job.\r\n    $HashJobs | Receive-Job -ErrorAction SilentlyContinue -ErrorVariable JobErrors | ForEach-Object {\r\n        $MatchingFiles.Add(\r\n            [PSCustomObject]@{\r\n                \"File Name\" = $(Split-Path $_ -Leaf)\r\n                Path        = $_\r\n            }\r\n        )\r\n    }\r\n\r\n    # If we have any matching files, we'll output them here.\r\n    if ($MatchingFiles) {\r\n        Write-Warning -Message \"File with $Algorithm hash of $Hash found!\"\r\n        $MatchingFiles | Format-Table -AutoSize | Out-String | Write-Host\r\n        $MatchingFiles | Select-Object -ExpandProperty Path | ForEach-Object { $CustomFieldValue.Add($_) }\r\n    }\r\n    else {\r\n        Write-Host -Object \"No files found with $Hash.\"\r\n    }\r\n\r\n    # If we received any failures or errors, we'll output that here.\r\n    $FailedJobs = $HashJobs | Get-Job | Where-Object { $_.State -ne \"Completed\" -and $_.State -ne \"Running\" }\r\n    if ($FailedJobs -or $JobErrors) {\r\n        Write-Host \"\"\r\n        Write-Host \"[Error] Failed to get the hash of certain files due to an error.\"\r\n        $CustomFieldValue.Add(\" \")\r\n        $CustomFieldValue.Add(\"[Error] Failed to get the hash of certain files due to an error.\")\r\n        if ($JobErrors) {\r\n            Write-Host \"\"\r\n            $JobErrors | ForEach-Object { Write-Host \"[Error] $($_.Exception.Message)\" }\r\n            $CustomFieldValue.Add(\" \")\r\n            $JobErrors | ForEach-Object { $CustomFieldValue.Add(\"[Error] $($_.Exception.Message)\") }\r\n        }\r\n        $ExitCode = 1\r\n    }\r\n\r\n    $HashJobs | Remove-Job -Force\r\n\r\n    # If we're given a custom field, we'll attempt to save the results to it.\r\n    if ($CustomField) {\r\n        try {\r\n            Write-Host \"Attempting to set Custom Field '$CustomField'.\"\r\n            Set-NinjaProperty -Name $CustomField -Value ($CustomFieldValue | Out-String)\r\n            Write-Host \"Successfully set Custom Field '$CustomField'!\"\r\n        }\r\n        catch {\r\n            if (-not $_.Exception.Message) {\r\n                Write-Host \"[Error] $($_.Message)\"\r\n            }\r\n            else {\r\n                Write-Host \"[Error] $($_.Exception.Message)\"\r\n            }\r\n            $ExitCode = 1\r\n        }\r\n        \r\n    }\r\n\r\n    exit $ExitCode\r\n}\r\nend {\r\n    \r\n    \r\n    \r\n}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Greifen Sie auf \u00fcber 300 Skripte im NinjaOne Dojo zu.<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Zugang erhalten<\/a><\/p>\n<\/div>\n<h2>Detailansicht<\/h2>\n<p>Das Skript beginnt mit Metadaten, einschlie\u00dflich einer Zusammenfassung, einer Beschreibung und einem Verwendungsbeispiel. Sie richtet Parameter ein, die die Benutzer:innen angeben k\u00f6nnen, z. B. den Hash-Wert, den Suchpfad, den Dateityp, den Hash-Algorithmus, die Timeout-Zeit und ein optionales benutzerdefiniertes Feld f\u00fcr die Ausgabeergebnisse.<\/p>\n<h3>Einstellung der Parameter<\/h3>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Hash<\/strong>: Der spezifische Hash-Wert, nach dem gesucht werden soll.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Suchpfad<\/strong>: Das Verzeichnis, in dem die Suche beginnen soll, standardm\u00e4\u00dfig &#8218;C:\\Windows&#8216;.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Dateityp<\/strong>: Die Dateierweiterung, nach der gefiltert werden soll.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\"><strong>Zeit\u00fcberschreitung<\/strong>: Die maximale Dauer der Suche, die standardm\u00e4\u00dfig 15 Minuten betr\u00e4gt.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\"><strong>Algorithmus<\/strong>: Der Hash-Algorithmus, der standardm\u00e4\u00dfig auf MD5 eingestellt ist.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"6\" data-aria-level=\"1\"><strong>Benutzerdefiniertes Feld<\/strong>: Ein optionales Feld zum Speichern der Ergebnisse.<\/li>\n<\/ul>\n<p>Das Skript passt diese Parameter dynamisch auf der Grundlage von Umgebungsvariablen an, wenn diese gesetzt sind.<\/p>\n<h3>\u00dcberpr\u00fcfung von Pfaden und Dateitypen<\/h3>\n<p>Das Skript validiert die Suchpfade und stellt sicher, dass sie existieren und korrekt formatiert sind. Es f\u00fcgt einen umgedrehten Schr\u00e4gstrich zu den Laufwerksbuchstaben hinzu, wenn dieser fehlt, und pr\u00fcft, ob der angegebene Pfad eine Datei statt eines Ordners ist. Wenn das der Fall ist, gibt es Warnmeldungen aus und passt die Parameter entsprechend an.<\/p>\n<h3>Job-Management f\u00fcr Hash-Berechnung<\/h3>\n<p>Um potenziell langwierige Hash-Berechnungen zu behandeln, verwendet das Skript PowerShell-Jobs. F\u00fcr jeden Suchpfad wird ein Job gestartet, der rekursiv nach Dateien mit der angegebenen Erweiterung sucht und deren Hash-Werte berechnet. Die Ergebnisse werden gesammelt und mit dem angegebenen Hash-Wert verglichen.<\/p>\n<h3>Zeit\u00fcberschreitung und Fehlerbehandlung<\/h3>\n<p>Das Skript enth\u00e4lt einen Timeout-Mechanismus, mit dem die Suche nach einer bestimmten Zeitspanne gestoppt wird, um zu verhindern, dass sie unendlich lange l\u00e4uft. Es sammelt alle Fehler, die w\u00e4hrend der Job-Ausf\u00fchrung auftreten, und gibt den Benutzer:innen detaillierte Fehlermeldungen.<\/p>\n<h3>Integration benutzerdefinierter Felder<\/h3>\n<p>Wenn ein benutzerdefiniertes Feld angegeben ist, versucht das Skript, die Ergebnisse mit der Funktion &#8218;Set-NinjaProperty&#8216; zu speichern, die verschiedene Arten von benutzerdefinierten Feldern verarbeitet und sicherstellt, dass die Daten korrekt formatiert sind und die Zeichengrenzen eingehalten werden.<\/p>\n<h3>Endg\u00fcltige Ausgabe<\/h3>\n<p>Das Skript gibt die \u00fcbereinstimmenden Dateien sowie alle aufgetretenen Fehler aus und versucht, das benutzerdefinierte Feld mit den Ergebnissen zu setzen. Am Ende wird der Vorgang mit einem entsprechenden Statuscode beendet, der vom Erfolg oder Misserfolg der Operationen abh\u00e4ngt.<\/p>\n<h2>Potenzielle Anwendungsf\u00e4lle<\/h2>\n<p>Stellen Sie sich einen IT-Experten vor, der f\u00fcr die Aufrechterhaltung der Integrit\u00e4t von Softwarebereitstellungs-Dateien in einem Netzwerk verantwortlich ist. Mit diesem Skript k\u00f6nnen sie Verzeichnisse, in denen Softwarepakete gespeichert sind, regelm\u00e4\u00dfig \u00fcberpr\u00fcfen und sicherstellen, dass keine unzul\u00e4ssigen \u00c4nderungen vorgenommen wurden. Wenn sich beispielsweise der Hash einer kritischen .exe-Datei \u00e4ndert, k\u00f6nnte dies auf eine Manipulation oder Besch\u00e4digung hindeuten und eine sofortige Untersuchung erforderlich machen.<\/p>\n<h2>Vergleiche<\/h2>\n<p>Herk\u00f6mmliche Methoden zur \u00dcberpr\u00fcfung der Dateiintegrit\u00e4t bestehen oft in manuellen Hash-Checks mit Tools wie &#8218;certutil&#8216; unter Windows. Dieses Skript automatisiert bzw. rationalisiert den Prozess und bietet eine effizientere und umfassendere L\u00f6sung. Au\u00dferdem l\u00e4sst es sich nahtlos in andere Skripte und Tools integrieren, die von IT-Experten verwendet werden, was seinen Nutzen in verschiedenen Szenarien erh\u00f6ht.<\/p>\n<h2>FAQs<\/h2>\n<p><strong>Wie kann ich mehrere Verzeichnisse f\u00fcr die Suche angeben?<\/strong><br \/>\nVerwenden Sie eine kommagetrennte Liste im Parameter &#8218;-SearchPath&#8216;.<\/p>\n<p><strong>Welche Hashing-Algorithmen werden unterst\u00fctzt?<\/strong><br \/>\nDas Skript unterst\u00fctzt MD5, SHA1, SHA256, SHA384 und SHA512.<\/p>\n<p><strong>Kann ich die Zeit\u00fcberschreitung \u00fcber 120 Minuten hinaus verl\u00e4ngern?<\/strong><br \/>\nNein, aus Leistungs- und Praktikabilit\u00e4tsgr\u00fcnden betr\u00e4gt die maximal zul\u00e4ssige Zeit\u00fcberschreitung 120 Minuten.<\/p>\n<h2>Folgen<\/h2>\n<p>Mit diesem Skript k\u00f6nnen IT-Experten f\u00fcr die Integrit\u00e4t wichtiger Dateien sorgen und so das Risiko von Sicherheitsverletzungen durch manipulierte oder besch\u00e4digte Dateien verringern. Durch die Automatisierung des Hash-Verifizierungsprozesses wird Zeit gespart und eine zuverl\u00e4ssige Methode zur Wahrung der Datenintegrit\u00e4t in gro\u00dfen Netzwerken geboten.<\/p>\n<h2>Empfehlungen<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\">Aktualisieren und pflegen Sie regelm\u00e4\u00dfig das Skript, um neue Hashing-Algorithmen und Dateitypen zu ber\u00fccksichtigen.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"8\" data-aria-level=\"1\">Planen Sie die Ausf\u00fchrung des Skripts in regelm\u00e4\u00dfigen Abst\u00e4nden, um die Dateiintegrit\u00e4t kontinuierlich zu \u00fcberwachen.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"9\" data-aria-level=\"1\">Verwenden Sie die Funktion f\u00fcr benutzerdefinierte Felder, um die Ergebnisse an einem zentralen Ort zu protokollieren, damit sie leicht zug\u00e4nglich und \u00fcberpr\u00fcfbar sind.<\/li>\n<\/ul>\n<h2>Abschlie\u00dfende \u00dcberlegungen<\/h2>\n<p>Die Integration von PowerShell-Skripten wie diesem zur Verifizierung von Datei-Hash-Werten in Ihre IT-Toolbox verbessert Ihre F\u00e4higkeit, <a href=\"https:\/\/www.ninjaone.com\/de\/blog\/erkennen-und-beheben-sie-sicherheitsrisiken-ihrer-mobilen-belegschaft\/\" target=\"_blank\" rel=\"noopener\">die Datenintegrit\u00e4t und -sicherheit zu gew\u00e4hrleisten<\/a>. Tools wie <a href=\"https:\/\/www.ninjaone.com\/de\/\" target=\"_blank\" rel=\"noopener\">NinjaOne<\/a> k\u00f6nnen diese Prozesse weiter rationalisieren und bieten erweiterte Funktionen und Integrationen, die die Verwaltung von IT-Systemen effizienter und effektiver machen. Durch den Einsatz dieser Technologien k\u00f6nnen IT-Experten ihre Umgebungen besser sch\u00fctzen und die Zuverl\u00e4ssigkeit ihrer Daten gew\u00e4hrleisten.<\/p>\n","protected":false},"author":35,"featured_media":0,"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":[4307,4306],"class_list":["post-383257","script_hub","type-script_hub","status-publish","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub\/383257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/comments?post=383257"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/media?parent=383257"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/operating_system?post=383257"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/use_cases?post=383257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}