{"id":208342,"date":"2023-08-29T08:56:51","date_gmt":"2023-08-29T08:56:51","guid":{"rendered":"https:\/\/www.ninjaone.com\/script-hub\/comment-verifier-espace-disque-script-powershell\/"},"modified":"2024-03-04T20:32:42","modified_gmt":"2024-03-04T20:32:42","slug":"comment-verifier-espace-disque-script-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/fr\/script-hub\/comment-verifier-espace-disque-script-powershell\/","title":{"rendered":"Comment v\u00e9rifier et surveiller l&rsquo;espace disque \u00e0 distance gr\u00e2ce \u00e0 un script PowerShell"},"content":{"rendered":"<p><strong>La surveillance de l&rsquo;espace disque<\/strong> est un \u00e9l\u00e9ment de base de l&rsquo;assistance informatique proactive, essentiel pour r\u00e9duire le nombre de tickets et maintenir l&rsquo;int\u00e9grit\u00e9 et la stabilit\u00e9 du syst\u00e8me. Le manque d&rsquo;espace disque peut \u00e9videmment \u00eatre \u00e0 l&rsquo;origine d&rsquo;un grand nombre de probl\u00e8mes et de plaintes de la part des utilisateurs (d\u00e9faillances d&rsquo;applications, pannes compl\u00e8tes du syst\u00e8me, etc.). La cr\u00e9ation d&rsquo;alertes lorsque les disques tombent en dessous d&rsquo;un seuil sp\u00e9cifi\u00e9 est un excellent moyen de pr\u00e9venir ces probl\u00e8mes. Cet article vous expliquera comment v\u00e9rifier la capacit\u00e9 du disque et alerter en cas d&rsquo;espace disque faible, \u00e0 distance et pour l&rsquo;ensemble de vos utilisateurs. Comment puis-je v\u00e9rifier l&rsquo;espace disque \u00e0 distance et envoyer une alerte lorsque l&rsquo;espace disque est faible ?<\/p>\n<ol>\n<li>Identifiez les lecteurs que vous souhaitez surveiller et ceux que vous souhaitez exclure (le cas \u00e9ch\u00e9ant).<\/li>\n<li>D\u00e9terminez les seuils d&rsquo;espace disque que vous souhaitez d\u00e9finir pour chaque type de lecteur.<\/li>\n<li>Personnalisez le script ci-dessous selon vos besoins.<\/li>\n<\/ol>\n<p>Ce script PowerShell est con\u00e7u pour alerter sur les disques qui sont en dessous d&rsquo;un pourcentage ou d&rsquo;une taille sp\u00e9cifi\u00e9e. Il fait la distinction entre les disques syst\u00e8me (ceux utilis\u00e9s pour d\u00e9marrer le syst\u00e8me d&rsquo;exploitation) et les disques de donn\u00e9es, offrant ainsi une vue d&rsquo;ensemble de l&rsquo;utilisation de l&rsquo;espace disque. Le script est polyvalent et personnalisable, ce qui vous permet de d\u00e9finir des param\u00e8tres pour les disques syst\u00e8me et les disques de donn\u00e9es s\u00e9par\u00e9ment. Vous pouvez sp\u00e9cifier l&rsquo;espace disponible minimum \u00e0 respecter, en pourcentage et en octets, et m\u00eame exclure certains disques de la v\u00e9rification. Cette flexibilit\u00e9 est id\u00e9ale pour tout <a href=\"https:\/\/www.ninjaone.com\/fr\/blog\/service-assistance-informatique-logiciel-helpesk-bonnes-pratiques\/\">professionnel de l&rsquo;informatique<\/a> ou <a href=\"https:\/\/www.ninjaone.com\/fr\/quest-ce-quun-msp\/\">MSP<\/a>.<\/p>\n<h2>Le script de surveillance de l&rsquo;espace disque :<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-group=\"require-terms\">#Requires -Version 2.0\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Alert on drive(s) that fall below a specified % or size. Distinguishes between System and Data drives.\r\n.DESCRIPTION\r\n    Alert on drive(s) that fall below a specified % or size. Distinguishes between System and Data drives.\r\n    The system drive is the drive(s) that are used to boot the OS.\r\n.EXAMPLE\r\n     -SystemDriveMinFreePercent 10 -SystemDriveMinFreeBytes 10GB -DataDriveMinFreePercent 20 -DataDriveMinFreeBytes 20GB\r\n    This checks all Drives\r\n.EXAMPLE\r\n     -ExcludeDrivesCustomField \"C,Z\" -SystemDriveMinFreePercentCustomField \"SystemDriveMinFreePercent\" -SystemDriveMinFreeBytes \"SystemDriveMinFreeBytes\" -DataDriveMinFreePercent \"DataDriveMinFreePercent\" -DataDriveMinFreeBytes \"DataDriveMinFreeBytes\"\r\n    This checks all Drives, except for C: and Z:.\r\n    Use this if you wish to to custom fields to specify the values from roles or globally.\r\n    This will pull the values from custom fields that would have otherwise been used from parameters.\r\n.EXAMPLE\r\n     -ExcludeDrivesByNameCustomField \"NoMonitor\" -SystemDriveMinFreePercentCustomField \"SystemDriveMinFreePercent\" -SystemDriveMinFreeBytes \"SystemDriveMinFreeBytes\" -DataDriveMinFreePercent \"DataDriveMinFreePercent\" -DataDriveMinFreeBytes \"DataDriveMinFreeBytes\"\r\n    This checks all Drives, except where a drive name\/label contains the text \"NoMonitor\".\r\n    Use this if you wish to to custom fields to specify the values from roles or globally.\r\n    This will pull the values from custom fields that would have otherwise been used from parameters.\r\n.EXAMPLE\r\n     No Parameters Specified\r\n    This checks all Drives with the defaults:\r\n        SystemDriveMinFreePercent   10%\r\n        SystemDriveMinFreeBytes     10GB\r\n        DataDriveMinFreePercent 20%\r\n        DataDriveMinFreeBytes   20GB\r\n.OUTPUTS\r\n    None\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 7, Windows Server 2012 R2\r\n    Release Notes:\r\n    Initial Release\r\n    (c) 2023 NinjaOne\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#&gt;\r\n\r\n[CmdletBinding()]\r\nparam (\r\n    [Parameter()]\r\n    [String]\r\n    $ExcludeDrives,\r\n    $ExcludeDrivesCustomField, # If set, get value from a custom field with this name.\r\n    [String]\r\n    $ExcludeDrivesByName,\r\n    $ExcludeDrivesByNameCustomField, # If set, get value from a custom field with this name.\r\n    $SystemDriveMinFreePercent = 10,\r\n    $SystemDriveMinFreePercentCustomField, # If set, get value from a custom field with this name.\r\n    $SystemDriveMinFreeBytes = 10GB,\r\n    $SystemDriveMinFreeBytesCustomField, # If set, get value from a custom field with this name.\r\n    $DataDriveMinFreePercent = 20,\r\n    $DataDriveMinFreePercentCustomField, # If set, get value from a custom field with this name.\r\n    $DataDriveMinFreeBytes = 20GB,\r\n    $DataDriveMinFreeBytesCustomField # If set, get value from a custom field with this name.\r\n)\r\n\r\nbegin {\r\n    function Get-Size {\r\n        param (\r\n            [string]$String\r\n        )\r\n        switch -wildcard ($String) {\r\n            '*PB' { [int64]$($String -replace '[^d+]+') * 1PB; break }\r\n            '*TB' { [int64]$($String -replace '[^d+]+') * 1TB; break }\r\n            '*GB' { [int64]$($String -replace '[^d+]+') * 1GB; break }\r\n            '*MB' { [int64]$($String -replace '[^d+]+') * 1MB; break }\r\n            '*KB' { [int64]$($String -replace '[^d+]+') * 1KB; break }\r\n            '*B' { [int64]$($String -replace '[^d+]+') * 1; break }\r\n            '*Bytes' { [int64]$($String -replace '[^d+]+') * 1; break }\r\n            Default { [int64]$($String -replace '[^d+]+') * 1 }\r\n        }\r\n    }\r\n    function Get-FriendlySize {\r\n        param($Bytes)\r\n        # Converts Bytes to the highest matching unit\r\n        $Sizes = 'Bytes,KB,MB,GB,TB,PB,EB,ZB' -split ','\r\n        for ($i = 0; ($Bytes -ge 1kb) -and ($i -lt $Sizes.Count); $i++) { $Bytes \/= 1kb }\r\n        $N = 2\r\n        if ($i -eq 0) { $N = 0 }\r\n        if ($Bytes) { \"$([System.Math]::Round($Bytes,$N)) $($Sizes[$i])\" }else { \"0 B\" }\r\n    }\r\n    function Invoke-DiskAlert {\r\n        param (\r\n            [PSObject[]]$Drives\r\n        )\r\n        $Drives | ForEach-Object {\r\n            $Type = if ($_.IsSystemDrive) { \"SystemDrive\" }else { \"DataDrive\" }\r\n            $Drive = $_\r\n            if ($Drive.totalSpace -and $Drive.freeSpace \/ $Drive.totalSpace * 100 -lt $Settings.\"$Type\".MinFreePercent) {\r\n                Write-Output \"$Type ($($Drive.driveName)) free space is under $($Settings.\"$Type\".MinFreePercent)% at $(Get-FriendlySize -Bytes $Drive.freeSpace)\"\r\n            }\r\n            elseif ($Drive.freeSpace -lt $Settings.$Type.MinFreeBytes) {\r\n                Write-Output \"$Type ($($Drive.driveName)) free space is under $(Get-FriendlySize -Bytes $Settings.\"$Type\".MinFreeBytes) at $(Get-FriendlySize -Bytes $Drive.freeSpace)\"\r\n            }\r\n        }\r\n    }\r\n    function Get-Drive {\r\n        param([string]$DriveName)\r\n        if ($(Get-Command -Name \"Get-CimInstance\")) {\r\n            Get-CimInstance -Query \"select * from Win32_DiskDrive\" | Where-Object { $_.Size } | ForEach-Object {\r\n                $d = $_\r\n                $d | ForEach-Object {\r\n                    $Disk = $_\r\n                    $p = Get-CimInstance -Query \"ASSOCIATORS OF {Win32_DiskDrive.DeviceID='$($Disk.DeviceID)'}  WHERE AssocClass = Win32_DiskDriveToDiskPartition\"\r\n                    $p | ForEach-Object {\r\n                        $Partition = $_\r\n                        Get-CimInstance -Query \"ASSOCIATORS OF {Win32_DiskPartition.DeviceID='$($Partition.DeviceID)'} WHERE AssocClass = Win32_LogicalDiskToPartition\" | ForEach-Object {\r\n                            $ld = $_\r\n                            [PSCustomObject]@{\r\n                                driveName     = $ld.DeviceId # C:\r\n                                IsSystemDrive = if ($p | Where-Object { $_.BootPartition }) { $true }else { $false }\r\n                                freeSpace     = $ld.FreeSpace # in bytes\r\n                                totalSpace    = $ld.Size # in bytes\r\n                                fileSystem    = $ld.FileSystem # NTFS\r\n                                physicalName  = $d.Name # .PHYSICALDRIVE2\r\n                                diskName      = $d.Caption # WDC WD5001AALS-xxxxxx\r\n                                diskModel     = $d.Model # WDC WD5001AALS-xxxxxx\r\n                                diskInterface = $d.InterfaceType # IDE\r\n                                mediaStatus   = $d.Status # OK\r\n                                volumeName    = $ld.VolumeName # System\r\n                                volumeSerial  = $ld.VolumeSerialNumber # 12345678\r\n                            }\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n        else {\r\n            Get-WmiObject -Query \"select * from Win32_DiskDrive\" | Where-Object { $_.Size } | ForEach-Object {\r\n                $d = $_\r\n                $d | ForEach-Object {\r\n                    $Disk = $_\r\n                    $p = Get-WmiObject -Query \"ASSOCIATORS OF {Win32_DiskDrive.DeviceID='$($Disk.DeviceID)'}  WHERE AssocClass = Win32_DiskDriveToDiskPartition\"\r\n                    $p | ForEach-Object {\r\n                        $Partition = $_\r\n                        Get-WmiObject -Query \"ASSOCIATORS OF {Win32_DiskPartition.DeviceID='$($Partition.DeviceID)'} WHERE AssocClass = Win32_LogicalDiskToPartition\" | ForEach-Object {\r\n                            $ld = $_\r\n                            [PSCustomObject]@{\r\n                                driveName     = $ld.DeviceId # C:\r\n                                IsSystemDrive = if ($p | Where-Object { $_.BootPartition }) { $true }else { $false }\r\n                                freeSpace     = $ld.FreeSpace # in bytes\r\n                                totalSpace    = $ld.Size # in bytes\r\n                                fileSystem    = $ld.FileSystem # NTFS\r\n                                physicalName  = $d.Name # .PHYSICALDRIVE2\r\n                                diskName      = $d.Caption # WDC WD5001AALS-xxxxxx\r\n                                diskModel     = $d.Model # WDC WD5001AALS-xxxxxx\r\n                                diskInterface = $d.InterfaceType # IDE\r\n                                mediaStatus   = $d.Status # OK\r\n                                volumeName    = $ld.VolumeName # System\r\n                                volumeSerial  = $ld.VolumeSerialNumber # 12345678\r\n                            }\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\nprocess {\r\n    # Get values from parameters\r\n    $Settings = [PSCustomObject]@{\r\n        SystemDrive = [PSCustomObject]@{\r\n            MinFreePercent = if ($env:SystemDriveMinFreePercent) { $env:SystemDriveMinFreePercent -replace '%' }else { $SystemDriveMinFreePercent }\r\n            MinFreeBytes   = if ($env:SystemDriveMinFreeBytes) { Get-Size -Size $env:SystemDriveMinFreeBytes }else { $SystemDriveMinFreeBytes }\r\n        }\r\n        DataDrive   = [PSCustomObject]@{\r\n            MinFreePercent = if ($env:DataDriveMinFreePercent) { $env:DataDriveMinFreePercent -replace '%' }else { $DataDriveMinFreePercent }\r\n            MinFreeBytes   = if ($env:DataDriveMinFreeBytes) { Get-Size -Size $env:DataDriveMinFreeBytes }else { $DataDriveMinFreeBytes }\r\n        }\r\n    }\r\n    # Get values from custom field\r\n    if ($SystemDriveMinFreePercentCustomField) {\r\n        $Settings.SystemDrive.MinFreePercent = Ninja-Property-Get -Name $SystemDriveMinFreePercentCustomField\r\n    }\r\n    if ($SystemDriveMinFreeBytesCustomField) {\r\n        $Settings.SystemDrive.MinFreeBytes = Ninja-Property-Get -Name $SystemDriveMinFreeBytesCustomField\r\n    }\r\n    if ($DataDriveMinFreePercentCustomField) {\r\n        $Settings.DataDrive.MinFreePercent = Ninja-Property-Get -Name $DataDriveMinFreePercentCustomField\r\n    }\r\n    if ($DataDriveMinFreeBytesCustomField) {\r\n        $Settings.DataDrive.MinFreeBytes = Ninja-Property-Get -Name $DataDriveMinFreeBytesCustomField\r\n    }\r\n    if ($env:ExcludeDrives) {\r\n        $ExcludeDrives = $env:ExcludeDrives\r\n    }\r\n    if ($ExcludeDrivesCustomField) {\r\n        $ExcludeDrives = Ninja-Property-Get -Name $ExcludeDrivesCustomField\r\n    }\r\n    if ($env:ExcludeDrivesByName) {\r\n        $ExcludeDrivesByName = $env:ExcludeDrivesByName\r\n    }\r\n    if ($env:ExcludeDrivesByNameCustomField) {\r\n        $ExcludeDrivesByNameCustomField = $env:ExcludeDrivesByNameCustomField\r\n    }\r\n\r\n    # System.IO.DriveInfo is usable as far back as .NET 2.0 for Windows 7 compatibility.\r\n    # Reference: https:\/\/learn.microsoft.com\/en-us\/dotnet\/api\/system.io.driveinfo?view=netstandard-2.0\r\n\r\n    # Get drives that are in the ready state\r\n    $Drives = Get-Drive\r\n\r\n    $Results = if ($Drives) {\r\n        $DrivesFiltered = if ($ExcludeDrivesByName) {\r\n            $Drives | Where-Object { $_.volumeName -notlike \"*$ExcludeDrivesByName*\" }\r\n        }\r\n        else { $Drive }\r\n\r\n        if ($ExcludeDrives) {\r\n            $DriveAlerts = Invoke-DiskAlert -Drives $DrivesFiltered\r\n            $DriveList = if ($ExcludeDrives -like \"*,*\") {\r\n                $ExcludeDrives -split ',' | Sort-Object -Unique\r\n            }\r\n            else {\r\n                $ExcludeDrives -split '' | Sort-Object -Unique | Select-Object -Skip 1\r\n            }\r\n            $DriveList | ForEach-Object {\r\n                $Drive = $_\r\n                $DriveAlerts | Where-Object { $_ -notlike \"*$($Drive):*\" }\r\n            }\r\n            \r\n        }\r\n        else {\r\n            Invoke-DiskAlert -Drives $Drives $DrivesFiltered\r\n        }\r\n    }\r\n    else {\r\n        # Should never get here, how was the script executed?!\r\n        \"No drives found?!\" | Out-String | Write-Host\r\n        exit 2\r\n    }\r\n\r\n    if ($Results) {\r\n        $Results | Out-String | Write-Host\r\n        exit 1\r\n    }\r\n    else {\r\n        Write-Host \"No drives found with low free space.\"\r\n        exit 0\r\n    }\r\n}\r\nend {\r\n    $ScriptVariables = @(\r\n        [PSCustomObject]@{\r\n            name           = \"Exclude Drives\"\r\n            calculatedName = \"excludedrives\"\r\n            required       = $false\r\n            defaultValue   = $null\r\n            valueType      = \"TEXT\"\r\n            valueList      = $null\r\n            description    = \"List if mounted drives to exclude from low drive check. Example: CFZ or C,F,Z\"\r\n        }\r\n        [PSCustomObject]@{\r\n            name           = \"Exclude Drives Custom Field\"\r\n            calculatedName = \"excludedrivescustomfield\"\r\n            required       = $false\r\n            defaultValue   = $null\r\n            valueType      = \"TEXT\"\r\n            valueList      = $null\r\n            description    = \"A custom field to get the value from. List if mounted drives to exclude from low drive check. Example: CFZ or C,F,Z\"\r\n        }\r\n        [PSCustomObject]@{\r\n            name           = \"Exclude Drives By Name\"\r\n            calculatedName = \"excludedrivesbyname\"\r\n            required       = $false\r\n            defaultValue   = $null\r\n            valueType      = \"TEXT\"\r\n            valueList      = $null\r\n            description    = \"Exclude drives with with the specified text in it's name\/label.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            name           = \"Exclude Drives By Name Custom Field\"\r\n            calculatedName = \"excludedrivesbynamecustomfield\"\r\n            required       = $false\r\n            defaultValue   = $null\r\n            valueType      = \"TEXT\"\r\n            valueList      = $null\r\n            description    = \"A custom field to get the value from. Exclude drives with with the specified text in it's name\/label.\"\r\n        }\r\n        [PSCustomObject]@{\r\n            name           = \"System Drive Minimum Size in Percent\"\r\n            calculatedName = \"systemdriveminfreepercent\"\r\n            required       = $false\r\n            defaultValue   = [PSCustomObject]@{\r\n                type  = \"TEXT\"\r\n                value = \"10%\"\r\n            }\r\n            valueType      = \"TEXT\"\r\n            valueList      = $null\r\n            description    = \"The percentage of free space to alert on when the OS drive is below this percentage. Example: 50 or 50%\"\r\n        }\r\n        [PSCustomObject]@{\r\n            name           = \"System Drive Minimum Size in Bytes\"\r\n            calculatedName = \"systemdriveminfreebytes\"\r\n            required       = $false\r\n            defaultValue   = [PSCustomObject]@{\r\n                type  = \"TEXT\"\r\n                value = \"10GB\"\r\n            }\r\n            valueType      = \"TEXT\"\r\n            valueList      = $null\r\n            description    = \"The minimum free space to alert on when the OS drive is below this amount. Example: 50GB, 50000MB, or 53687091200\"\r\n        }\r\n        [PSCustomObject]@{\r\n            name           = \"Data Drive Minimum Size in Percent\"\r\n            calculatedName = \"datadriveminfreepercent\"\r\n            required       = $false\r\n            defaultValue   = [PSCustomObject]@{\r\n                type  = \"TEXT\"\r\n                value = \"20%\"\r\n            }\r\n            valueType      = \"TEXT\"\r\n            valueList      = $null\r\n            description    = \"The percentage of free space to alert on when a Data drive is below this percentage. Example: 50 or 50%\"\r\n        }\r\n        [PSCustomObject]@{\r\n            name           = \"Data Drive Minimum Size in Bytes\"\r\n            calculatedName = \"datadriveminfreebytes\"\r\n            required       = $false\r\n            defaultValue   = [PSCustomObject]@{\r\n                type  = \"TEXT\"\r\n                value = \"20GB\"\r\n            }\r\n            valueType      = \"TEXT\"\r\n            valueList      = $null\r\n            description    = \"The minimum free space to alert on when the Data drive is below this amount. Example: 50GB, 50000MB, or 53687091200\"\r\n        }\r\n        [PSCustomObject]@{\r\n            name           = \"System Drive Minimum Size in Percent Custom Field\"\r\n            calculatedName = \"systemdriveminfreepercentcustomfield\"\r\n            required       = $false\r\n            defaultValue   = $null\r\n            valueType      = \"TEXT\"\r\n            valueList      = $null\r\n            description    = \"A custom field to get the value from. The percentage of free space to alert on when the OS drive is below this percentage. Example: 50 or 50%\"\r\n        }\r\n        [PSCustomObject]@{\r\n            name           = \"System Drive Minimum Size in Bytes Custom Field\"\r\n            calculatedName = \"systemdriveminfreebytescustomfield\"\r\n            required       = $false\r\n            defaultValue   = $null\r\n            valueType      = \"TEXT\"\r\n            valueList      = $null\r\n            description    = \"A custom field to get the value from. The minimum free space to alert on when the OS drive is below this amount. Example: 50GB, 50000MB, or 53687091200\"\r\n        }\r\n        [PSCustomObject]@{\r\n            name           = \"Data Drive Minimum Size in Percent Custom Field\"\r\n            calculatedName = \"datadriveminfreepercentscustomfield\"\r\n            required       = $false\r\n            defaultValue   = $null\r\n            valueType      = \"TEXT\"\r\n            valueList      = $null\r\n            description    = \"A custom field to get the value from. The percentage of free space to alert on when a Data drive is below this percentage. Example: 50 or 50%\"\r\n        }\r\n        [PSCustomObject]@{\r\n            name           = \"Data Drive Minimum Size in Bytes Custom Field\"\r\n            calculatedName = \"datadriveminfreebytescustomfield\"\r\n            required       = $false\r\n            defaultValue   = $null\r\n            valueType      = \"TEXT\"\r\n            valueList      = $null\r\n            description    = \"A custom field to get the value from. The minimum free space to alert on when the Data drive is below this amount. Example: 50GB, 50000MB, or 53687091200\"\r\n        }\r\n    )\r\n    $ScriptName = \"Condition Low Disk Space Alert\"\r\n}<\/pre>\n\n<div class=\"in-context-cta\"><p>Acc\u00e9dez \u00e0 plus de 700 scripts dans le Dojo NinjaOne <a href=\"https:\/\/app.ninjarmm.com\/auth\/?return_to=https%3A%2F%2Fninjarmm.zendesk.com%2Fhc%2Fen-us%2Fsections%2F360012866471-Script-Share#\/register\" target=\"_blank\" rel=\"noopener\">Obtenez votre acc\u00e8s<\/a><\/p>\n<\/div>\n<h2>Fonctionnement du script de surveillance de l&rsquo;espace disque<\/h2>\n<p>Le script commence par recueillir des informations sur tous les disques du syst\u00e8me. Il filtre ensuite les disques que vous avez choisi d&rsquo;exclure, et v\u00e9rifie les autres en fonction des param\u00e8tres que vous avez d\u00e9finis. Si un disque passe en dessous de l&rsquo;espace disponible minimum \u00e0 respecter,, le script vous en avertit, ce qui vous permet de prendre des mesures avant que le probl\u00e8me ne soit r\u00e9el. L&rsquo;une des caract\u00e9ristiques les plus remarquables de ce script est sa capacit\u00e9 \u00e0 extraire des valeurs de champs personnalis\u00e9s. Cela signifie que vous pouvez sp\u00e9cifier des valeurs globalement ou \u00e0 partir de r\u00f4les, ce qui ajoute un autre niveau de personnalisation au script.<\/p>\n<h2>Transformez la gestion informatique gr\u00e2ce \u00e0 NinjaOne<\/h2>\n<p>Bien qu&rsquo;il soit possible de surveiller l&rsquo;espace disque strictement \u00e0 l&rsquo;aide de PowerShell depuis un ordinateur local, il existe un moyen encore meilleur de g\u00e9rer vos ressources informatiques, \u00e0 distance et \u00e0 grande \u00e9chelle : NinjaOne. NinjaOne est une <a href=\"https:\/\/www.ninjaone.com\/fr\/operations-informatiques-unifiees\/\">plateforme de gestion informatique unifi\u00e9e<\/a> qui int\u00e8gre des \u00e9tapes de rem\u00e9diation (\u00e0 l&rsquo;aide de scripts si n\u00e9cessaire) dans des strat\u00e9gies d&rsquo;appareil tr\u00e8s flexibles qui d\u00e9terminent quand les seuils d&rsquo;alerte sont atteints ainsi que les \u00e9tapes \u00e0 suivre. NinjaOne donne acc\u00e8s \u00e0 des centaines de scripts qui peuvent vous \u00eatre tr\u00e8s utiles et vous permet de cr\u00e9er vos propres scripts dans pratiquement n&rsquo;importe quel langage de script. NinjaOne peut vous aider \u00e0 <a href=\"https:\/\/www.ninjaone.com\/fr\/plateforme-de-gestion-de-terminaux\/\">surveiller et \u00e0 g\u00e9rer tous vos terminaux informatiques<\/a> \u00e0 grande \u00e9chelle et \u00e0 partir d&rsquo;un seul tableau de bord. Gr\u00e2ce aux strat\u00e9gies et aux scripts, vous pouvez automatiser pratiquement toutes les t\u00e2ches de routine, de l&rsquo;installation de correctifs logiciels \u00e0 la g\u00e9n\u00e9ration de rapports, ce qui vous permet de gagner du temps et de g\u00e9rer les difficult\u00e9s de fa\u00e7on proactive, avant qu&rsquo;elles ne se transforment en probl\u00e8mes.<\/p>\n","protected":false},"author":35,"featured_media":206562,"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":[4287],"class_list":["post-208342","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows","use_cases-configuration-de-systeme"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/script_hub\/208342","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=208342"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/media\/206562"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/media?parent=208342"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/operating_system?post=208342"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/use_cases?post=208342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}