{"id":392408,"date":"2024-12-16T09:43:09","date_gmt":"2024-12-16T09:43:09","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=392408"},"modified":"2024-12-16T09:43:09","modified_gmt":"2024-12-16T09:43:09","slug":"sauvegarde-du-journal-des-evenements-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/fr\/script-hub\/sauvegarde-du-journal-des-evenements-powershell\/","title":{"rendered":"Script PowerShell pour la sauvegarde du journal des \u00e9v\u00e9nements\u00a0: guide complet pour les professionnels de l&rsquo;informatique\u00a0"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Dans le domaine de la gestion informatique, la conservation du journal des \u00e9v\u00e9nements du syst\u00e8me pr\u00e9cis est essentielle pour le d\u00e9pannage, la conformit\u00e9 et la s\u00e9curit\u00e9. Cependant, la gestion manuelle de ces journaux peut prendre beaucoup de temps, en particulier dans les grands environnements. Pour y rem\u00e9dier, <strong>l&rsquo;automatisation de la sauvegarde des journaux d&rsquo;\u00e9v\u00e9nements \u00e0 l&rsquo;aide de <a href=\"https:\/\/www.ninjaone.com\/it-hub\/endpoint-management\/what-is-powershell\/\">PowerShell<\/a><\/strong> est une solution pratique et efficace. Ce guide pr\u00e9sente un script PowerShell efficace con\u00e7u pour exporter et compresser les journaux d&rsquo;\u00e9v\u00e9nements, offrant ainsi une approche rationalis\u00e9e de la gestion des journaux d&rsquo;\u00e9v\u00e9nements.<\/p>\n<h2>Contexte<\/h2>\n<p>Les journaux d&rsquo;\u00e9v\u00e9nements sont essentiels pour comprendre l&rsquo;activit\u00e9 du syst\u00e8me et diagnostiquer les probl\u00e8mes. Ces journaux enregistrent des informations telles que les erreurs syst\u00e8me, les failles de s\u00e9curit\u00e9 et les \u00e9v\u00e9nements li\u00e9s aux applications, ce qui les rend inestimables pour les administrateurs syst\u00e8me et les <a href=\"https:\/\/www.ninjaone.com\/what-is-an-msp\/\">fournisseurs de services g\u00e9r\u00e9s (MSP)<\/a>. Le script fourni automatise le processus de sauvegarde, garantissant que les journaux sont export\u00e9s, compress\u00e9s et stock\u00e9s en toute s\u00e9curit\u00e9 sans n\u00e9cessiter d&rsquo;intervention manuelle.<\/p>\n<p>Ce script est particuli\u00e8rement utile pour les environnements soumis \u00e0 des exigences r\u00e9glementaires strictes, telles que la HIPAA ou la <a href=\"https:\/\/www.ninjaone.com\/blog\/what-is-gdpr-compliance\/\">RGPD<\/a>, o\u00f9 le maintien de pistes d&rsquo;audit d\u00e9taill\u00e9es est obligatoire.<\/p>\n<h2>Le script\u00a0:<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Exports the specified event logs to a specified location in a compressed zip file.\r\n.DESCRIPTION\r\n    Exports the specified event logs to a specified location in a compressed zip file.\r\n    The event logs can be exported from a specific date range.\r\n\r\n    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.\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\r\nPARAMETER: -EventLogs \"System,Security\" -BackupDestination \"C:\\Temp\\EventLogs\\\"\r\n    Exports the specified event logs to a specified location in a compressed zip file.\r\n.EXAMPLE\r\n    -EventLogs \"System,Security\" -BackupDestination \"C:\\Temp\\EventLogs\\\"\r\n    ## EXAMPLE OUTPUT WITH EventLogs ##\r\n    [Info] Today is 2023-04-17\r\n    [Info] EventLogs are System,Security\r\n    [Info] Backup Destination is C:\\Temp\\EventLogs\\\r\n    [Info] Start Date is null\r\n    [Info] End Date is null\r\n    [Info] Exporting Event Logs...\r\n    [Info] Exported Event Logs to C:\\Temp\\EventLogs\\System.evtx\r\n    [Info] Exported Event Logs to C:\\Temp\\EventLogs\\Security.evtx\r\n    [Info] Successfully exported Event Logs!\r\n    [Info] Compressing Event Logs...\r\n    [Info] Compressed Event Logs to C:\\Temp\\EventLogs\\Backup-System-Security-2023-04-17.zip\r\n    [Info] Successfully compressed Event Logs!\r\n    [Info] Removing Temporary Event Logs...\r\n    [Info] Removed Temporary Event Logs!\r\n\r\nPARAMETER: -EventLogs \"System,Security\" -BackupDestination \"C:\\Temp\\EventLogs\\\" -StartDate \"2023-04-15\" -EndDate \"2023-04-15\"\r\n    Exports the specified event logs to a specified location in a compressed zip file.\r\n    The event logs can be exported from a specific date range.\r\n.EXAMPLE\r\n    -EventLogs \"System,Security\" -BackupDestination \"C:\\Temp\\EventLogs\\\" -StartDate \"2023-04-15\" -EndDate \"2023-04-15\"\r\n    ## EXAMPLE OUTPUT WITH StartDate and EndDate ##\r\n    [Info] Today is 2023-04-17\r\n    [Info] EventLogs are System,Security\r\n    [Info] Backup Destination is C:\\Temp\\EventLogs\\\r\n    [Info] Start Date is 2023-04-15\r\n    [Info] End Date is 2023-04-16\r\n    [Info] Exporting Event Logs...\r\n    [Info] Exported Event Logs to C:\\Temp\\EventLogs\\System.evtx\r\n    [Info] Exported Event Logs to C:\\Temp\\EventLogs\\Security.evtx\r\n    [Info] Successfully exported Event Logs!\r\n    [Info] Compressing Event Logs...\r\n    [Info] Compressed Event Logs to C:\\Temp\\EventLogs\\Backup-System-Security-2023-04-17.zip\r\n    [Info] Successfully compressed Event Logs!\r\n    [Info] Removing Temporary Event Logs...\r\n    [Info] Removed Temporary Event Logs!\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows Server 2016\r\n    Release Notes: Initial Release\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nparam (\r\n    [String]$EventLogs,\r\n    [String]$BackupDestination,\r\n    [DateTime]$StartDate,\r\n    [DateTime]$EndDate\r\n)\r\n\r\nbegin {\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\nprocess {\r\n    if (-not (Test-IsElevated)) {\r\n        Write-Host \"[Error] Access Denied. Please run with Administrator privileges.\"\r\n        exit 1\r\n    }\r\n    if ($env:eventLogs -and $env:eventLogs -notlike \"null\") {\r\n        $EventLogs = $env:eventLogs\r\n    }\r\n    \r\n    $EventLogNames = $EventLogs -split \",\" | ForEach-Object { $_.Trim() }\r\n    if ($env:backupDestination -and $env:backupDestination -notlike \"null\") {\r\n        $BackupDestination = $env:backupDestination\r\n    }\r\n    if ($env:startDate -and $env:startDate -notlike \"null\") {\r\n        $StartDate = $env:startDate\r\n    }\r\n    if ($env:endDate -and $env:endDate -notlike \"null\") {\r\n        $EndDate = $env:endDate\r\n    }\r\n\r\n    # Validate StartDate and EndDate\r\n    if ($StartDate) {\r\n        try {\r\n            $StartDate = Get-Date -Date $StartDate -ErrorAction Stop\r\n        }\r\n        catch {\r\n            Write-Host \"[Error] The specified start date is not a valid date.\"\r\n            exit 1\r\n        }\r\n    }\r\n    if ($EndDate) {\r\n        try {\r\n            $EndDate = Get-Date -Date $EndDate -ErrorAction Stop\r\n        }\r\n        catch {\r\n            Write-Host \"[Error] The specified end date is not a valid date.\"\r\n            exit 1\r\n        }\r\n    }\r\n    # Validate BackupDestination is a valid path to a folder\r\n    if ($(Test-Path -Path $BackupDestination -PathType Container -ErrorAction SilentlyContinue)) {\r\n        $BackupDestination = Get-Item -Path $BackupDestination\r\n    }\r\n    else {\r\n        try {\r\n            $BackupDestination = New-Item -Path $BackupDestination -ItemType Directory -ErrorAction Stop\r\n        }\r\n        catch {\r\n            Write-Host \"[Error] The specified backup destination is not a valid path to a folder.\"\r\n            exit 1\r\n        }\r\n    }\r\n\r\n    Write-Host \"[Info] Today is $(Get-Date -Format yyyy-MM-dd-HH-mm)\"\r\n\r\n    # Validate EventLogs are valid event logs\r\n    if (\r\n        $(\r\n            wevtutil.exe el | ForEach-Object {\r\n                if ($EventLogNames -and $($EventLogNames -contains $_ -or $EventLogNames -like $_)) { $_ }\r\n            }\r\n        ).Count -eq 0\r\n    ) {\r\n        Write-Host \"[Error] No Event Logs matching: $EventLogNames\"\r\n    }\r\n\r\n    Write-Host \"[Info] EventLogs are $EventLogNames\"\r\n    if ($EventLogNames -and $EventLogNames.Count -gt 0) {\r\n        Write-Host \"[Info] Backup Destination is $BackupDestination\"\r\n\r\n        # If the start date is specified, check if it's a valid date\r\n        if ($StartDate) {\r\n            try {\r\n                $StartDate = $(Get-Date -Date $StartDate).ToUniversalTime()\r\n            }\r\n            catch {\r\n                Write-Host \"[Error] The specified start date is not a valid date.\"\r\n                exit 1\r\n            }\r\n            Write-Host \"[Info] Start Date is $(Get-Date -Date $StartDate -Format yyyy-MM-dd-HH-mm)\"\r\n        }\r\n        else {\r\n            Write-Host \"[Info] Start Date is null\"\r\n        }\r\n        if ($EndDate) {\r\n            try {\r\n                $EndDate = $(Get-Date -Date $EndDate).ToUniversalTime()\r\n            }\r\n            catch {\r\n                Write-Host \"[Error] The specified end date is not a valid date.\"\r\n                exit 1\r\n            }\r\n            Write-Host \"[Info] End Date is $(Get-Date -Date $EndDate -Format yyyy-MM-dd-HH-mm)\"\r\n        }\r\n        else {\r\n            Write-Host \"[Info] End Date is null\"\r\n        }\r\n\r\n        # Check if the start date after the end date\r\n        if ($StartDate -and $EndDate -and $StartDate -gt $EndDate) {\r\n            # Flip the dates if the start date is after the end date\r\n            $OldEndDate = $EndDate\r\n            $OldStartDate = $StartDate\r\n            $EndDate = $OldStartDate\r\n            $StartDate = $OldEndDate\r\n            Write-Host \"[Info] Start Date is after the end date. Flipping dates.\"\r\n        }\r\n\r\n        Write-Host \"[Info] Exporting Event Logs...\"\r\n        foreach ($EventLog in $EventLogNames) {\r\n            $EventLogPath = $(Join-Path -Path $BackupDestination -ChildPath \"$EventLog.evtx\")\r\n            try {\r\n                if ($StartDate -and $EndDate) {\r\n                    wevtutil.exe epl \"$EventLog\" \"$EventLogPath\" \/ow:true \/query:\"*[System[TimeCreated[@SystemTime&gt;='$(Get-Date -Date $StartDate -UFormat \"%Y-%m-%dT%H:%M:%S\")' and @SystemTime&lt;='$(Get-Date -Date $EndDate -UFormat \"%Y-%m-%dT%H:%M:%S\")']]]\" 2&gt;$null\r\n                }\r\n                elseif ($StartDate) {\r\n                    wevtutil.exe epl \"$EventLog\" \"$EventLogPath\" \/ow:true \/query:\"*[System[TimeCreated[@SystemTime&gt;='$(Get-Date -Date $StartDate -UFormat \"%Y-%m-%dT%H:%M:%S\")']]]\" 2&gt;$null\r\n                }\r\n                elseif ($EndDate) {\r\n                    wevtutil.exe epl \"$EventLog\" \"$EventLogPath\" \/ow:true \/query:\"*[System[TimeCreated[@SystemTime&lt;='$(Get-Date -Date $EndDate -UFormat \"%Y-%m-%dT%H:%M:%S\")']]]\" 2&gt;$null\r\n                }\r\n                else {\r\n                    wevtutil.exe epl \"$EventLog\" \"$EventLogPath\" \/ow:true \/query:\"*[System[TimeCreated[@SystemTime&gt;='1970-01-01T00:00:00']]]\" 2&gt;$null\r\n                }\r\n                if ($(Test-Path -Path $EventLogPath -ErrorAction SilentlyContinue)) {\r\n                    # Get the number of events in the log\r\n                    $EventCount = $(Get-WinEvent -Path $EventLogPath -ErrorAction SilentlyContinue).Count\r\n                    if ($EventCount -and $EventCount -gt 0) {\r\n                        Write-Host \"[Info] Found $EventCount events from $EventLog\"\r\n                    }\r\n                    else {\r\n                        Write-Host \"[Warn] No events found in $EventLog\"\r\n                        continue\r\n                    }\r\n                    Write-Host \"[Info] Exported Event Logs to $EventLogPath\"\r\n                }\r\n                else {\r\n                    throw\r\n                }\r\n            }\r\n            catch {\r\n                Write-Host \"[Error] Failed to export event logs $EventLog\"\r\n                continue\r\n            }\r\n        }\r\n\r\n        Write-Host \"[Info] Compressing Event Logs...\"\r\n\r\n        # Get the event log paths that where created\r\n        $JoinedPaths = foreach ($EventLog in $EventLogNames) {\r\n            # Join the Backup Destination and the Event Log Name\r\n            $JoinedPath = Join-Path -Path $BackupDestination -ChildPath \"$EventLog.evtx\" -ErrorAction SilentlyContinue\r\n            if ($(Test-Path -Path $JoinedPath -ErrorAction SilentlyContinue)) {\r\n                # Get the saved event log path\r\n                Get-Item -Path $JoinedPath -ErrorAction SilentlyContinue\r\n            }\r\n        }\r\n        $JoinedPaths = $JoinedPaths | Where-Object { $(Test-Path -Path $_ -ErrorAction SilentlyContinue) }\r\n\r\n        try {\r\n            # Create a destination path to save the compressed file to\r\n            # &lt;Folder&gt;Backup-&lt;EventLogName-EventLogName&gt;-&lt;Date&gt;.zip\r\n            $Destination = Join-Path -Path $($BackupDestination) -ChildPath $(\r\n                @(\r\n                    \"Backup-\",\r\n                    $($EventLogNames -join '-'),\r\n                    \"-\",\r\n                    $(Get-Date -Format yyyy-MM-dd-HH-mm),\r\n                    \".zip\"\r\n                ) -join ''\r\n            )\r\n\r\n            $CompressArchiveSplat = @{\r\n                Path            = $JoinedPaths\r\n                DestinationPath = $Destination\r\n                Update          = $true\r\n            }\r\n\r\n            # # If the destination path already exists, update the archive instead of creating a new one\r\n            # if ($(Test-Path -Path $Destination -ErrorAction SilentlyContinue)) {\r\n            #     $CompressArchiveSplat.Add(\"Update\", $true)\r\n            # }\r\n\r\n            # Compress the Event Logs\r\n            $CompressError = $true\r\n            $ErrorCount = 0\r\n            $SecondsToSleep = 1\r\n            $TimeOut = 120\r\n            while ($CompressError) {\r\n                try {\r\n                    $CompressError = $false\r\n                    Compress-Archive @CompressArchiveSplat -ErrorAction Stop\r\n                    break\r\n                }\r\n                catch {\r\n                    $CompressError = $true\r\n                }\r\n\r\n                if ($CompressError) {\r\n                    if ($ErrorCount -gt $TimeOut) {\r\n                        Write-Host \"[Warn] Skipping compression... Timed out.\"\r\n                    }\r\n                    if ($ErrorCount -eq 0) {\r\n                        Write-Host \"[Info] Waiting for wevtutil.exe to close file.\"\r\n                    }\r\n                    Start-Sleep -Seconds $SecondsToSleep\r\n                }\r\n                $ErrorCount++\r\n            }\r\n            if ($CompressError) {\r\n                Write-Host \"[Error] Failed to Compress Event Logs.\"\r\n            }\r\n            else {\r\n                Write-Host \"[Info] Compressed Event Logs to $($Destination)\"\r\n            }\r\n        }\r\n        catch {\r\n            Write-Host \"[Error] Failed to compress event logs.\"\r\n        }\r\n\r\n        if ($(Test-Path -Path $Destination -ErrorAction SilentlyContinue)) {\r\n            Write-Host \"[Info] Removing Temporary Event Logs...\"\r\n            foreach ($EventLogPath in $JoinedPaths) {\r\n                try {\r\n                    Remove-Item -Path $EventLogPath -Force -ErrorAction SilentlyContinue\r\n                    Write-Host \"[Info] Removed Temporary Event Logs: $EventLogPath\"\r\n                }\r\n                catch {}\r\n            }\r\n        }\r\n        else {\r\n            Write-Host \"[Info] Renaming Event Logs...\"\r\n            foreach ($EventLogPath in $JoinedPaths) {\r\n                if ($(Test-Path -Path $EventLogPath -ErrorAction SilentlyContinue)) {\r\n                    try {\r\n                        $NewPath = Rename-Item -Path $EventLogPath -NewName \"$($EventLogPath.BaseName)-$(Get-Date -Format yyyy-MM-dd-HH-mm).evtx\" -PassThru -ErrorAction Stop\r\n                        Write-Host \"[Info] Event Logs saved to: $NewPath\"\r\n                    }\r\n                    catch {\r\n                        Write-Host \"[Info] Event Logs saved to: $EventLogPath\"\r\n                    }\r\n                }\r\n                else {\r\n                    Write-Host \"[Info] Event Logs saved to: $EventLogPath\"\r\n                }\r\n            }\r\n        }\r\n    }\r\n    else {\r\n        Write-Host \"[Error] No Event Logs were specified.\"\r\n        exit 1\r\n    }\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>Gagnez du temps gr\u00e2ce \u00e0 plus de 300 scripts du Dojo NinjaOne.<\/p>\n<p>\u2192 <a class=\"waffle-rich-text-link\" href=\"https:\/\/www.ninjaone.com\/fr\/phase-de-test-gratuit\/\">Obtenir l&rsquo;acc\u00e8s<\/a><\/p>\n<\/div>\n<h2>Description d\u00e9taill\u00e9e<\/h2>\n<p>Le script est structur\u00e9 de mani\u00e8re \u00e0 atteindre les objectifs suivants\u00a0:<\/p>\n<ol>\n<li><strong>Exporter les journaux d&rsquo;\u00e9v\u00e9nements<\/strong>\u00a0: pour extraire des journaux sp\u00e9cifiques (par exemple, syst\u00e8me, s\u00e9curit\u00e9) en fonction des donn\u00e9es fournies par l&rsquo;administrateur.<\/li>\n<li><strong>Filtrage des dates<\/strong>\u00a0: il est possible de filtrer les journaux en fonction des dates de d\u00e9but et de fin.<\/li>\n<li><strong>Compression<\/strong>\u00a0: pour enregistrer les journaux export\u00e9s sous la forme d&rsquo;un fichier .zip compress\u00e9 afin d&rsquo;optimiser le stockage.<\/li>\n<li><strong>Nettoyage<\/strong>\u00a0: pour supprimer les fichiers journaux temporaires apr\u00e8s la compression.<\/li>\n<\/ol>\n<h2>Composants cl\u00e9s<\/h2>\n<h3>1. Contr\u00f4les pr\u00e9liminaires<\/h3>\n<ul>\n<li><strong>Privil\u00e8ges administrateur<\/strong>\u00a0: la fonction Test-IsElevated permet de s&rsquo;assurer que le script est ex\u00e9cut\u00e9 avec des autorisations \u00e9lev\u00e9es.<\/li>\n<li><strong>Validation des entr\u00e9es<\/strong>\u00a0: valide les entr\u00e9es de l&rsquo;utilisateur pour les journaux d&rsquo;\u00e9v\u00e9nements, les dates et la destination de la sauvegarde.<\/li>\n<\/ul>\n<h3>2. Exportation des journaux<\/h3>\n<ul>\n<li>Les journaux sont export\u00e9s \u00e0 l&rsquo;aide de wevtutil.exe.<\/li>\n<li>Le script permet de filtrer les dates \u00e0 l&rsquo;aide de la fonction Get-Date de PowerShell pour une extraction pr\u00e9cise des journaux.<\/li>\n<li>Produit des fichiers .evtx dans le r\u00e9pertoire de sauvegarde sp\u00e9cifi\u00e9.<\/li>\n<\/ul>\n<h3>3. Compression<\/h3>\n<ul>\n<li>La commande Compress-Archive est utilis\u00e9e pour regrouper les journaux export\u00e9s dans un fichier .zip.<\/li>\n<li>Le fichier compress\u00e9 est nomm\u00e9 dynamiquement pour inclure les noms des journaux d&rsquo;\u00e9v\u00e9nements et la date du jour.<\/li>\n<\/ul>\n<h3>4. Nettoyage<\/h3>\n<ul>\n<li>Les fichiers .evtx temporaires sont supprim\u00e9s apr\u00e8s une compression r\u00e9ussie pour \u00e9conomiser de l&rsquo;espace.<\/li>\n<\/ul>\n<h2>Cas d&rsquo;utilisation potentiels de la sauvegarde du journal des \u00e9v\u00e9nements<\/h2>\n<h3>\u00c9tude de cas\u00a0: Gestion des journaux pour les MSP<\/h3>\n<p>Un fournisseur de services g\u00e9r\u00e9s (MSP) supervise 100 machines clientes. Pour se conformer aux exigences r\u00e9glementaires, les journaux doivent \u00eatre sauvegard\u00e9s chaque semaine. En utilisant ce script\u00a0:<\/p>\n<ol>\n<li>Le MSP planifie le script via le planificateur de t\u00e2ches pour qu&rsquo;il s&rsquo;ex\u00e9cute tous les dimanches.<\/li>\n<li>Les journaux de \u00ab\u00a0Syst\u00e8me\u00a0\u00bb et de \u00ab\u00a0S\u00e9curit\u00e9\u00a0\u00bb sont export\u00e9s pour la semaine et sauvegard\u00e9s dans un r\u00e9f\u00e9rentiel de sauvegarde central.<\/li>\n<li>Les sauvegardes compress\u00e9es sont archiv\u00e9es, ce qui lib\u00e8re de l&rsquo;espace de stockage tout en garantissant l&rsquo;acc\u00e8s aux journaux pour les audits.<\/li>\n<\/ol>\n<h2>Comparaisons<\/h2>\n<h3>M\u00e9thode manuelle<\/h3>\n<ul>\n<li><strong>Chronophage<\/strong> : l&rsquo;exportation et la compression manuelles des journaux n\u00e9cessitent des efforts importants.<\/li>\n<li><strong>Sujet \u00e0 erreur<\/strong> : risque accru d&rsquo;absence de journaux ou de cr\u00e9ation de sauvegardes incompl\u00e8tes.<\/li>\n<\/ul>\n<h3>Utilisation d&rsquo;outils tiers<\/h3>\n<ul>\n<li><strong>Avantages<\/strong> : des outils tels que Splunk offrent des analyses avanc\u00e9es mais peuvent \u00eatre co\u00fbteux.<\/li>\n<li><strong>Avantages du script<\/strong> : ce script PowerShell est gratuit, personnalisable et s&rsquo;int\u00e8gre parfaitement dans les environnements Windows existants.<\/li>\n<\/ul>\n<h2>FAQ<\/h2>\n<h3>Quels journaux d&rsquo;\u00e9v\u00e9nements ce script peut-il sauvegarder\u00a0?<\/h3>\n<p>Le script prend en charge tous les journaux disponibles via wevtutil.exe, tels que les journaux du syst\u00e8me, de la s\u00e9curit\u00e9 et des applications.<\/p>\n<h3>Puis-je programmer ce script\u00a0?<\/h3>\n<p>Oui, utilisez le planificateur de t\u00e2ches pour automatiser le script des sauvegardes r\u00e9guli\u00e8res.<\/p>\n<h3>Comment fonctionne le filtrage par date\u00a0?<\/h3>\n<p>Indiquez les dates de d\u00e9but et de fin pour extraire les journaux d&rsquo;une p\u00e9riode sp\u00e9cifique. Le script valide et inverse les dates si n\u00e9cessaire.<\/p>\n<h3>Que se passe-t-il si le script rencontre une erreur\u00a0?<\/h3>\n<p>Les erreurs, telles que les chemins d&rsquo;acc\u00e8s non valides ou les journaux manquants, sont enregistr\u00e9es et g\u00e9r\u00e9es de mani\u00e8re \u00e9l\u00e9gante afin d&rsquo;\u00e9viter l&rsquo;arr\u00eat du script.<\/p>\n<h2>Implications<\/h2>\n<p>L&rsquo;automatisation des sauvegardes des journaux d&rsquo;\u00e9v\u00e9nements \u00e0 l&rsquo;aide de ce script renforce la s\u00e9curit\u00e9 informatique en garantissant l&rsquo;archivage coh\u00e9rent des journaux. Il soutient \u00e9galement les efforts de mise en conformit\u00e9 en conservant des enregistrements accessibles et horodat\u00e9s. De plus, en cas de <a href=\"https:\/\/www.ninjaone.com\/it-hub\/endpoint-security\/what-is-a-data-breach\/\">violation<\/a> ou de d\u00e9faillance du syst\u00e8me, ces sauvegardes peuvent \u00eatre essentielles pour l&rsquo;analyse des erreurs.<\/p>\n<h2>Recommandations<\/h2>\n<ul>\n<li><strong>Ex\u00e9cutez en tant qu&rsquo;administrateur<\/strong> : garantissez des privil\u00e8ges \u00e9lev\u00e9s pour acc\u00e9der \u00e0 tous les journaux d&rsquo;\u00e9v\u00e9nements.<\/li>\n<li><strong>Planifiez des sauvegardes r\u00e9guli\u00e8res<\/strong> : utilisez le planificateur de t\u00e2ches ou des outils similaires pour automatiser les sauvegardes p\u00e9riodiques.<\/li>\n<li><strong>Emplacements de sauvegarde s\u00e9curis\u00e9s<\/strong> : stockez les journaux compress\u00e9s dans un endroit s\u00fbr, de pr\u00e9f\u00e9rence chiffr\u00e9, afin d&rsquo;\u00e9viter tout acc\u00e8s non autoris\u00e9.<\/li>\n<li><strong>Testez avant de d\u00e9ployer<\/strong> : ex\u00e9cutez le script dans un environnement de test pour valider sa fonctionnalit\u00e9.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>La gestion des journaux d&rsquo;\u00e9v\u00e9nements fait partie int\u00e9grante des op\u00e9rations informatiques, et l&rsquo;automatisation de ce processus \u00e0 l&rsquo;aide de PowerShell simplifie une t\u00e2che g\u00e9n\u00e9ralement fastidieuse. Ce script garantit non seulement des sauvegardes coh\u00e9rentes, mais il offre \u00e9galement la possibilit\u00e9 de personnaliser et d&rsquo;adapter les sauvegardes \u00e0 des environnements vari\u00e9s.<\/p>\n<p>Pour les MSP et les professionnels de l&rsquo;informatique \u00e0 la recherche de solutions de gestion informatique compl\u00e8tes,\u00a0<strong>NinjaOne<\/strong>\u00a0 propose des outils qui compl\u00e8tent les scripts de ce type, permettant de rationaliser les op\u00e9rations informatiques et de renforcer la s\u00e9curit\u00e9.<\/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":[4284],"class_list":["post-392408","script_hub","type-script_hub","status-publish","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/script_hub\/392408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/comments?post=392408"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/media?parent=392408"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/operating_system?post=392408"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/use_cases?post=392408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}