> For the complete documentation index, see [llms.txt](https://docs.glesys.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.glesys.com/products/bare-metal/dedicated-servers/how-tos/raid-monitoring-with-storcli-in-windows-server-2025.md).

# RAID monitoring with StorCLI in Windows Server 2025

***

Start by downloading StorCLI from Broadcom's website (<https://docs.broadcom.com/docs/1232743397>).

Unzip the zip file on the dedicated server. Inside is a folder (*storcli\_rel*) with another zip file (*Unified\_storcli\_all\_os.zip*). Unzip that file as well.

In the unzipped folder, navigate to **Unfied\_storcli\_all\_os → Unified\_storcli\_all\_os → Windows**. Copy the file `storcli64.exe` to your home folder. In this guide, we'll use *C:\Users\Administrator*.

## Querying the RAID controller

Open a Terminal window and navigate to where you copied `storcli64.exe`, for example, *C:\Users\Administrator*, if you aren't in the folder already.

{% code title="Command" %}

```
cd C:\Users\Administrator
```

{% endcode %}

Let's try to view the status of the RAID controller card:

{% code title="Command" %}

```
.\storcli64.exe /call show all
```

{% endcode %}

This will output several pages of information about the controller. To only get the current status of the controller card, you can use the JSON output and filter it, like so:

<pre data-title="Command and output (command is highlighted)"><code><strong>(.\storcli64.exe /call show all j | ConvertFrom-Json).Controllers[0]."Response Data".Status."Controller Status"
</strong>Optimal
</code></pre>

## Automating the monitoring

This script will send you an email if the status is not "Optimal". The script will be scheduled in the *Task Scheduler* to run once a day. Further, the script will run as the SYSTEM account.

### Generating the SMTP credentials file

Since the script will run as the SYSTEM account, and you generally don't want login credentials lying around in plain text, you first need to create a credentials file for the SMTP server as the SYSTEM account.

To be able to execute commands as the SYSTEM account, you first need to download the `psexec64` command. Execute the following command in a Terminal (with a PowerShell session):

{% code title="Command" %}

```ps1
Invoke-WebRequest -Uri "https://live.sysinternals.com/PsExec64.exe" -OutFile "C:\Windows\System32\PsExec64.exe"
```

{% endcode %}

Now, execute the following command to open a new PowerShell session as the SYSTEM account:

{% code title="Command" %}

```ps1
PsExec64.exe -s -i powershell.exe
```

{% endcode %}

Finally, create the credentials file for the SMTP server using the following command. Adjust the path and filename to where you want to save the credentials file:

{% code title="Command" %}

```ps1
Get-Credential | Export-Clixml -Path C:\Users\Administrator\emailcreds.xml
```

{% endcode %}

An interactive dialog box will now open. Enter your username and password for the SMTP server you intend to use to send email alerts.

<figure><img src="/files/qRAUyCDLdLDBiyDAFBkm" alt=""><figcaption></figcaption></figure>

### Creating the script

The script will connect to an SMTP server to send the email. In this example, we'll use Glesys's email service. For this to work, you first need to create an email account. See [Create an email account](/products/other/email/how-tos/create-an-email-account.md) for more information. You can, however, use any SMTP server you have access to.

Create a file called `raidcheck.ps1` with the following content. Place it in your home folder. Make sure to change the `$StorCLI` variable to where you copied `storcli64.exe`. Also, set the path for the `$Creds` variable to where you saved the credentials file for the email server.

You must also change the `$From` and `$To` variables to real email addresses (and `$SmtpServer` and `$Port` if you don't intend to use Glesys's email service).

{% code title="raidcheck.ps1" %}

```ps1
$SmtpServer = "mail.glesys.se"
$From = "info@example.se"
$To = "reports@example.com"
$Subject = "Controller Status Alert"
$Port = 587
$StorCLI = "C:\Users\Administrator\storcli64.exe"
$Creds = Import-Clixml -Path C:\Users\Administrator\emailcreds.xml
if (-not $?)
{
    Write-Host "Could not get credentials from file" -f Red
    exit 1
}

$json_data = & $StorCLI \call show all j | Out-String
if (-not $?)
{
    Write-Host "Could not execute storcli64" -f Red
    exit 1
}

$data = $json_data | ConvertFrom-Json
$status = $data.Controllers[0]."Response Data".Status."Controller Status"
#$status = "Email test" # Uncomment to test the email function

Write-Host "Current Controller Status: $status"

if ($status -ne "Optimal")
{
    $message = "Warning: The controller status is not Optimal.`n`nCurrent Status: $status`n`nDetails:`n$json_data"

    Send-MailMessage `
        -SmtpServer $SmtpServer `
        -Credential $Creds `
        -From $From `
        -To $To `
        -Subject $Subject `
        -UseSsl `
        -Port $Port `
        -Body $message

    Write-Host "Email notification sent about the controller's non-optimal status." -f Red
}
else
{
    Write-Host "Controller status is Optimal" -f Green
}
```

{% endcode %}

### Manual test run

Since the SYSTEM account owns the credentials file, you have to run any tests of the script from a PowerShell session started by the SYSTEM account. Execute the `psexec64.exe` command as before to launch a new PowerShell session:

{% code title="Command" %}

```
PsExec64.exe -s -i powershell.exe
```

{% endcode %}

Now, in the newly opened Terminal window, test the script:

<pre data-title="Multiple ommands and output (commands are highlighted)"><code><strong>cd C:\Users\Administrator
</strong><strong>.\raidcheck.ps1
</strong>Current Controller Status: Optimal
Controller status is Optimal 
</code></pre>

To also test the email function, uncomment the test code by removing the `#` in front of `$status` (the line with the text "Uncomment to test the email function"):

{% code title="Uncommented test line in raidcheck.ps1" %}

```
$status = "Email test" # Uncomment to test the email function
```

{% endcode %}

Run the script again:

<pre data-title="Command and output (command is highlighted)"><code><strong>.\raidcheck.ps1
</strong>Current Controller Status: Email test
Email notification sent about the controller's non-optimal status. 
</code></pre>

You should now receive an email, which includes the complete JSON output from the command.

Don't forget to comment out the test code once you have verified that the email is working, by putting a `#` in front of the line again, like so:

{% code title="Line in raidcheck.ps1" %}

```
#$status = "Email test" # Uncomment to test the email function
```

{% endcode %}

### Schedule the script

The final piece of the puzzle is to schedule the script so it runs every day.

Start the **Task Scheduler** by clicking the Start menu and searching for *task scheduler*. Once it appears, click on it.

<figure><img src="/files/NwVqL6P1un5YjOTJk8Yn" alt=""><figcaption></figcaption></figure>

In the Task Scheduler, click **Create Basic Task...**

<figure><img src="/files/TdwhS0CFLI9Jbs8lAnUt" alt=""><figcaption></figcaption></figure>

When the guide starts, give the new task a name, such as **RAID check**. Then, click **Next**.

<figure><img src="/files/r3Apbjeip0In3rMI7e9q" alt=""><figcaption></figcaption></figure>

Select to trigger the task **Daily**. Click **Next**.

<figure><img src="/files/KF70GkuaaYlC9xKBInQS" alt=""><figcaption></figcaption></figure>

Make sure that the task is set to recur every 1 day. Click **Next**.

<figure><img src="/files/jUALlXGhoR8k9IykA5tI" alt=""><figcaption></figcaption></figure>

Select **Start a program** and click **Next**.

<figure><img src="/files/Ba208cwPcoutIlvzma10" alt=""><figcaption></figcaption></figure>

Now you need to enter the program to execute.&#x20;

* In the *Program/script* field, type `powershell.exe`
* In the *Add arguments* field, type `-NonInteractive -File "C:\Users\Administrator\raidcheck.ps1"` (but change the path if you have saved the script somewhere else).

Then, click **Next**.

<figure><img src="/files/Rip508QGvQoKp2o2xbYl" alt=""><figcaption></figcaption></figure>

You are going to need to tweak the task a bit, so select **Open the Properties dialog for this task when I click Finish**. Then, click **Finish**.

<figure><img src="/files/vO51hG7ObQizlUv1kWYI" alt=""><figcaption></figcaption></figure>

Click **Change User or Group...**

<figure><img src="/files/v77HK0VAaoelfHBO78sN" alt=""><figcaption></figcaption></figure>

First, type **SYSTEM** in the text field. Then, click **Check Names**. SYSTEM will now become underlined in the text field. Finally, click **OK**.

<figure><img src="/files/27MmYfxNo2B5BATCgeWl" alt=""><figcaption></figcaption></figure>

In the properties dialog, it should now say `NT AUTHORITY/SYSTEM` to the left of the *Change Users and Groups* button. If so, save the new task by clicking **OK**.

<figure><img src="/files/wAEpJJk0MipAiM9lSKOS" alt=""><figcaption></figcaption></figure>

The task is now scheduled to run every day.&#x20;

#### Enabling history (optional)

If you would like to view the history of each run, you can enable it by clicking **Enable All Tasks History**. However, this is optional and not needed for the task to run. But it can be helpful for troubleshooting.

<figure><img src="/files/DC4s69p9hXfA0EVViLoo" alt=""><figcaption></figcaption></figure>

## Notes

We recommend that you test the script to ensure that it truly works before putting it into live operation. There's no guarantee it will suit your specific server and setup.
