Monitoring with PowerShell Chapter 2: Monitoring Compellent SANs

Hi All,
Today we will be focusing on monitoring the Compellent SAN status from a single server, Most Compellents are delivered with Dell’s Co-Pilot functionality and do not require you to monitor it yourself, but I also enjoy having an extra set of eyes on my shared storage – Also in some security restricted environments we cannot use the Co-pilot functionality and have to rely on our own monitoring sets.

Requirements:

  • Compellent PowerShell components(Link)
  • PowerShell v3 or higher

Creating the monitoring sets:
Creating the monitoring sets are very simple and straight-forward, after we install the Dell Compellent PowerShell Components we get the ability to connect to the SAN by importing the modules and using the Get-SCConnection cmdlet.


Add-PSSnapin Compellent.StorageCenter.PSSnapin
$pass = ConvertTo-SecureString "ThisIsYourAdminPassword" -AsPlainText -force
$connection = Get-SCConnection -HostName YOURSAN.DOMAIN.COM -User Admin -Password $pass
$SanAlerts = Get-SCAlert -Connection $connection

As you can see, this is not very secure – The password is stored plain-text in the script and could be read by anyone, so before moving on to the monitoring part we’re going to make sure we’re connecting more securely than just using plain-text credentials.

To start encrypting our credentials we’ll be generating a secure key to store as a file, this file will need to be placed in a secure location that no-one except you(or better: the script) can access it. I always advice that you create a new keypair for each script, so if for whatever reason one key is leaked to the public not all your scripts are affected.


$Key = New-Object Byte[] 32
[Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($Key)
$Key | out-file "C:\SecureKeyStorage\CompellentScript.key"

After creating this key, we can start encrypting and decrypting passwords with it. To do this we’ll create a new password file.


$Key = Get-Content $KeyFile"C:\SecureKeyStorage\CompellentScript.key"
$Password = " ThisIsYourAdminPassword" | ConvertTo-SecureString -AsPlainText -Force
$Password | ConvertFrom-SecureString -key $Key | Out-File "C:\SecureKeyStorage\CompellentScript.Password"

Now, we change our script to use the encrypted password+keyfile combination instead of the credentials object we’ve created before.


$KeyFile = get-content "C:\SecureKeyStorage\CompellentScript.key"
$PasswordFile = get-content "C:\SecureKeyStorage\CompellentScript.Password"
$Pass =  $PasswordFile | ConvertTo-SecureString -Key $key
Add-PSSnapin Compellent.StorageCenter.PSSnapin
$connection = Get-SCConnection -HostName YOURSAN.DOMAIN.COM -User Admin -Password $pass
$SanAlerts = Get-SCAlert -Connection $connection

Now that we have connected to the SAN we can start retrieving the warning and errors using the following script:


$KeyFile = get-content "C:\SecureKeyStorage\CompellentScript.key"
$PasswordFile = get-content "C:\SecureKeyStorage\CompellentScript.Password"
$Pass =  $PasswordFile | ConvertTo-SecureString -Key $key
Add-PSSnapin Compellent.StorageCenter.PSSnapin
$connection = Get-SCConnection -HostName YOURSAN.DOMAIN.COM -User Admin -Password $pass
$SanAlerts = Get-SCAlert -Connection $connection

foreach($Alert in $SanAlerts | where-object { $_.Status -ne "Inform" }){
$SanStatus += "Alert: $($Alert.message) `n "
}
if (!$SanStatus) { $SanStatus = "Healthy” }

And that’s it! You now have all Alerts from your SAN in one handy location, excluding the “INFORM” reports.

Recent Articles

Automating with PowerShell: making stolen tokens useless with Global Secure Access

Last week I watched Merill Fernando talk to Alex Pavlovsky and Marilee Tuscak from the Entra team about something I’d kinda put under the “needs a GSA licence” branch and i’d check it out later, turns out that like most people, I half-assed the documentation and it turns out it doesn’t. There’s two features that come with any P1 license; Compliant network check and Source IP Restoration. So BP, P1, or even frontline worker licenses already have this.

CIPP ❤️ #IntuneForMSPs

We’re Joining #IntuneForMSPs 🎉

Being invited by Microsoft to join a global initiative is a big moment for us, and we want to be clear about why it matters. #IntuneForMSPs is Microsoft’s program to help MSPs deliver Microsoft 365, Intune, and Copilot services at scale, and CIPP is now part of it, bringing the largest MSP community in the channel directly to Microsoft.

The return of CyberDrain CTF

CyberDrain CTF returns! (and so do I!)

It’s been since september that I actually picked up a digital pen equivalent and wrote anything down. This was due to me being busy with life but also my side projects like CIPP. I’m trying to get back into the game of scripting and blogging about these scripts. There’s still so much to automate and so little time, right? ;)