Powershell : Storage Space Direct (S2D) rapport de l’état des disques physiques

Hello,

Voici un petit script à planifier chaque jour, permettant d’obtenir un rapport de l’état des disques physiques d’un cluster Storage Space Direct (S2D) :

$credential = Get-Credential -Message "Please fill in your credentials :"

$scriptBlock = {
    $allDisks = Get-PhysicalDisk *ATA*
    $countDisk = $allDisks.count
    $failedDisks = ($allDisks | ? {$_.HealthStatus -inotlike "*Healthy*"}).count

    [string]$body = $alldisks | Select FriendlyName, SerialNumber, OperationalStatus, HealthStatus, Usage, @{Name="Size(GB)";Expression={[math]::Round([decimal]$_.Size/1gb,0)}} | Sort "Size(GB)" | ConvertTo-Html -Head "<style>table {border-collapse: collapse;padding:5px;}table, th, td {border: 1px solid black;}th{white-space: nowrap;background-color:lightgrey;}</style>" -PreContent "<p>Dear,<br /><br />Please find bellow the list of all physical disks and their current health status on the S2D cluster :</p>" -PostContent '<p><br />Regards,<br /><br />Your IT Server Team</p>'

    Send-MailMessage -Body $body -BodyAsHtml -From "no-reply@your-domain.com" -To "your-email@your-domain.com" -Subject "[S2D] $failedDisks physical disk failed over $countDisk" -Priority High -SmtpServer "mailserver.your-domain.com"
}

Invoke-Command -ScriptBlock $scriptBlock -ComputerName "s2d-cluster" -Credential $credential

N’oubliez pas de modifier les variables pour que ce script fonctionne dans votre environnement. 🙂

Le mail reçu devrait ressembler à ceci :

 

Bonne journée !

Laisser un commentaire