Compellent PSCS One-Liner Coding: Tip #1

Posted Leave a commentPosted in Compellent, Development, PowerShell

The Compellent Storage Center provides in-depth reporting, alerting, and monitoring as part of the platform.  It’s very important for Storage Administrators to monitor and review the alerts (informational or otherwise) that might be generated on their Storage Center.

By design, alerts in the Storage Center will change the “stop-light” status from green to red, especially critical alerts where, for example, a component is malfunctioning or a path between the controllers and disk are down.  It is also by design that these alerts have to be acknowledged one-by-one in the Storage Center interface.

That being said, there are times when you might be performing some configuration changes or maintenance that could trigger alerts.  Having to acknowledge 10 alerts is one thing, but lets say you replaced a switch, and lets say there are now 50 alerts.  How can I acknowledge those quickly and easily using the Compellent Storage Center PowerShell Command Set?

Like this:

Get-SCAlert -ConnectionName SC12 | foreach {Acknowledge-SCAlert -Index $_.Index -ConnectionName SC12}

This will get a list of alerts from the connection I have previously saved using the Get-SCConnection cmdlet.  We then pipe that to the Acknowledge-SCAlert cmdlet which then acknowledges the alert on the Storage Center.  I just cleared my 50 alerts in less than a minute!

NOTE: It really is important to review the alerts that your system might be generating.  Use all script examples with caution.

Seattle Tech Field Day

Posted Leave a commentPosted in Compellent, Storage

I’m still getting caught up on events, so I thought I’d share with you a little about our participation in the 2010 Tech Field Day held in Seattle, WA. 

Back in the middle of July, Compellent had an opportunity to participate in Gestalt IT Tech Field Day.  As it says on their website, “This unique event brings together innovative IT product vendors and independent thought leaders, allowing them to get to know one another. It is a forum for engagement, education, hands-on experience, and feedback.”

Compellent was thrilled to be part of the experience as one of five sponsors for this event.  Others included F5, NEC, Veeam, and Nimble Storage, who used Tech Field Day as their official launch.

The event focused around these different vendors who had the opportunity to present their technologies to an esteemed panel of delegates.  The delegates, which comprised of technologists and bloggers, came from around the world.

The evening of July 15th included a reception and dinner at the Boeing Museum of Flight.  This was about the coolest thing I’ve seen.  I have a love for aviation, but to see where some of the first aircraft were built was simply amazing. 

First Flying Machine

The welcome reception was held in the “Red Barn”.  This is the original Boeing airplane factory.  The smell of the wood barn interior makes you feel like you were there.  Seeing the woodshop tools that were used to create the different components of the flying machine was pretty cool.

Red Barn - The Original Boeing Airplane Factory

This was an opportunity for us to meet the other vendors in attendance, but more importantly to meet all of the delegates and learn more about them and what they do.  Liem Nguyen, the director of Corporate Communications for Compellent helped to coordinate Compellent’s sponsorship and involvement, and is seen below with Kirby Wadsworth, a marketing exec with F5 Networks.  You can’t tell from this picture, but Kirby was rockin’ some pretty sweet yellow slacks that night.

Liem Nguyen (Compellent) and Kirby Wadsworth (F5 Networks)

Most of the delegates in one form or another were involved in IT, but specifically this Tech Field Day was focused on virtualization.  So, the basis of what we talked about centered around our virtualized storage solution, but also the integration points with Hyper-V and VMware.

Bob Fine, Director of Product Marketing, Scott DesBles, Director of Technical Solutions, and myself tag-teamed to present the Compellent solution.  Bob and Scott provided the Compellent overview and a roadmap discussion which seemed to keep the panel engaged, and we also discussed Live Volume while demonstrating the Compellent Storage Center and its ease of use in addition to Enterprise Manager, the “single pane of glass” which can be used to manage multiple Storage Centers in your environment and the interface that enables the world-famous “6 clicks to replicate a volume’”. 

Check out Liem’s blog post about Tech Field Day with some exclusive interview footage of the delegates and shots from the Museum of Flight.

We had a blast meeting with the delegates and other vendors in Seattle.  We’d love the opportunity to do this again and continue to share the Compellent story.

Cargo plane on approach, Mount Rainer in background

Did I mention the view in Seattle?  For this last picture, I was amazed at how close the parking lot was to the runway at Boeing Field.  We were able to get some great photos and videos of the experience.  Here’s a nice shot of a cargo aircraft on approach with Mount Rainer in the distance.

Search Your Compellent Storage Center Using Windows PowerShell

Posted Leave a commentPosted in Compellent, PowerShell

Using Windows PowerShell and the Compellent Storage Center Command Set for PowerShell, I have created a simple script that performs searches for server and volume objects providing results of each in addition to their related mappings.  This can be helpful if you have multiple levels of server or volume folders.

# Name:       Storage Center Search
# Usage:      Search for volume or server objects across a Storage Center
# Author:     Justin Braun
# Date:              February 17, 2010

# This sample script is provided "as is" with no warranty whatsoever; 
# you assume all responsibilty of the consequences of use.

$scname = Read-Host "What Storage Center do you want to search? (IP or hostname)"
$scusername = Read-Host "What is the username for your account on this Storage Center?"
$scpassword = Read-Host -AsSecureString -Prompt "What is the password?"
$findsource = Read-Host "What type of object are you looking for? (S=server, V=volume)"
$searchterm = Read-Host "Enter the text you want to search for (wildcards OK)"

if($findsource -ne "S" -and $findsource -ne "V")
{
       # Invalid parameter entered.
       Write-Host "`nInvalid search source specified.`n" -ForegroundColor Red
       Break
}

# Valid parameter found - start script

# Instantiate connection
Write-Host "`nOpening connection...";

try
{
       $conn = Get-SCConnection -HostName $scname -User $scusername -Password $scpassword;
}
catch
{
       Write-Host "Error: " $_;
       Break;
}

Write-Host "Connection established to $scname...";

# What are we searching for?
switch ($findsource)
{
       "S"
       {
              # Find a server
              $servers = Get-SCServer -Connection $conn | where { $_.Name -like $searchterm }

              if($servers -ne $null)
              {
                     # Found some objects that might match
                     Write-Host "`nThe following servers might match your query:"
                     $servers | ft -AutoSize Name, LogicalPath, WorldWideNames
              }
              else
              {
                     # No objects found
                     Write-Host "`nSorry, no objects were found that match your query."
              }
       }

       "V"
       {
              # Find a volume
              $vols = Get-SCVolume -Connection $conn | where { $_.Name -like $searchterm }

              if($vols -ne $null)
              {
                     # Found some objects that might match
                     Write-Host "`nThe following volumes might match your query:"

                     foreach($vol in $vols)
                     {
                           # Create an output object for table formatting
                           $obj = new-Object PSObject;

                           # Add member properties with their name and value pair
                           $obj | Add-Member NoteProperty VolumeName($vol.Name);
                           $obj | Add-Member NoteProperty LogicalPath($vol.LogicalPath);

                           #Get Mappings to volume
                           $mappings = Get-SCVolumeMap -VolumeIndex $vol.Index -Connection $conn

                           if($mappings -ne $null)
                           {
                                  $maps = ""
                                  foreach($mapping in $mappings)
                                  {
                                         $maps += $mapping.ServerName + " "
                                  }

                                  $obj | Add-Member NoteProperty Mappings($maps);
                           }
                           else
                           {
                                  # No mappings found
                                  $obj | Add-Member NoteProperty Mappings("None");
                           }

                           # Write the output to the screen
                           Write-Output $obj;
                     }
              }
              else
              {
                     # No objects found
                     Write-Host "`nSorry, no objects were found that match your query."
              }
       }
}

If you have ideas for scripts or would like to share your creations with other Compellent customers, check out the Forums at the Compellent Customer Portal. [authentication required]

Compellent Volume Reporting with PowerShell

Posted 3 CommentsPosted in Compellent, Development, PowerShell

Compellent Enterprise Manager works great for managing your Storage Center environment and providing reports on volume usage and utilization.

I was looking for a little different spin on the information.  I was looking for a cumulative volume count across an entire Storage Center, plus a total count of replays on the system, and how many of the volumes that exist are actually mapped up to a server object.

For example, the test system that I ran my script on determined that we had over 900 volumes with over 3,000 replays.  We also realized that we had some cleanup to do when we figured out that only 180 of the volumes were actually mapped up.

I did build into the script to collect the page count of each replay so you could tell how large they were if you wanted to; just the calculation needs to be added.

# NAME: VolumeInfo.ps1
# DESC: PowerShell script to report on volume information
# BY  : Justin Braun, Compellent Technologies, Inc.
# DATE: December 1, 2009
# VER : 1.0
#
# THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND.  THE ENTIRE
# RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
#
# NOTE: This script assumes a default Get-SCConnection already exists.
 
# Collection
$colVolumes = @()
 
foreach($volume in Get-SCVolume)
{
    Write-Host "Gathering volume data for $volume.Name..."
    
    $replays = $null
    $mappings = $null
    $pagecount = 0
    
    # Volume Information
    $ReportData = New-Object System.Object
    $ReportData | Add-Member -Type NoteProperty -Name "Volume Index" -Value $volume.Index
    $ReportData | Add-Member -Type NoteProperty -Name "Volume Name" -Value $volume.Name
    $ReportData | Add-Member -Type NoteProperty -Name "Volume Size" -Value $volume.Size
    $ReportData | Add-Member -Type NoteProperty -Name "Block Count" -Value $volume.BlockCount
    $ReportData | Add-Member -Type NoteProperty -Name "Created By" -Value $volume.CreateUser
    $ReportData | Add-Member -Type NoteProperty -Name "Created On" -Value $volume.CreateTime
    $ReportData | Add-Member -Type NoteProperty -Name "Modified By" -Value $volume.ModifyUser
    $ReportData | Add-Member -Type NoteProperty -Name "Modified On" -Value $volume.ModifyTime
    $ReportData | Add-Member -Type NoteProperty -Name "Folder" -Value $volume.ParentFolder
    
    # Replay Count Information
    Write-Host "Gathering replay information for $volume.Name..."
    $replays = Get-SCReplay -SourceVolumeIndex $volume.Index
    $ReportData | Add-Member -Type NoteProperty -Name "Replay Count" -Value $replays.Count
    
    # Replay Cumulative Page Information
    Write-Host "Gathering replay page count information for $volume.Name..."
    foreach($replay in $replays)
    {
        $pagecount += $replay.OwnedPageCount
    }
    
    $ReportData | Add-Member -Type NoteProperty -Name "Total Replay Pages" -Value $pagecount
    
    # Volume Mapping Information
    Write-Host "Gathering volume mapping information for $volume.Name..."
    $mappings = Get-SCVolumeMap -VolumeIndex $volume.Index
    
    if($mappings -eq $null)
    {
        $ReportData | Add-Member -Type NoteProperty -Name "Mappings" -Value "No"
    }
    else
    {
        $ReportData | Add-Member -Type NoteProperty -Name "Mappings" -Value "Yes"
    }
    
    # Add to collection
    $colVolumes += $ReportData
    
}
 
# Outfile ReportData Contents
Write-Host "Writing output file..."
 
$colVolumes | export-csv -path "c:\volumeinfo.txt"
 
Write-Host "Done!"

If you have any ideas on how this script could be more useful in your environment, drop me a comment below.

PowerShell with Compellent and Exchange 2010

Posted 2 CommentsPosted in Compellent, Development, Exchange, PowerShell

I’ve been doing lots of work in the lab lately with Exchange 2010 to understand all the new changes and how it works with the Compellent Storage Center.

With Exchange 2010, the concept of Storage Groups no longer exists.  Databases are the sole object and are a peer to the server now.  Database names must be unique, but can be moved from server to server as necessary.

In the past, I’ve shared some scripts on how to provision storage for an Exchange 2007 environment.  I’ve slightly reworked this script to account for no longer needing storage groups, but to also automatically create the mailbox database on the Exchange Server and mount it when completed.

# NAME: Exchange2010LabCreate.ps1
# DESC: PowerShell script to create and map volumes for Exchange 2010 Lab
# BY  : Justin Braun, Compellent Technologies, Inc.
# DATE: November 24, 2009
# VER : 1.0
#
# THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND.  THE ENTIRE
# RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
#
 
####################################################
# ERROR HANDLING
####################################################
    #"SilentlyContinue": do not print, continue 
    #"Continue": Print, continue (this is the default) 
    #"Stop": Halt the command or script 
    #"Inquire": Ask the user what to do 
    $ErrorActionPreference = "Inquire"
 
####################################################
# STORAGE CENTER CONFIGURATION INFORMATION
####################################################
    $schost = "storagecenter.lab.test"
    $user = "username"
    $pass = "password"
 
####################################################
# EXCHANGE STORAGE CONFIGURATION
####################################################    
    # Number of Databases Per Server
    $dbsize = "1TB"
    $dbtotal = 1
    $dbDiskFolder = "Assigned"
 
####################################################
# SERVER INFORMATION
####################################################
    # Server to Map To (server defintion on CSC must match server name in Windows because of VDS)
    $ServerName = "E2K10MBX01"
 
####################################################
# MISC. CONFIGURATION SETTINGS
####################################################
    # Volume folder name
    $SCParentFolderName = "E2K10MBX01"
    
    # Use custom disk folders for each volume? (if $false, then a single disk folder config is assumed)
    $useCustomDiskFolders = $false
    
    #Mountpoints (set to $true if mountpoint volumes weren't previously created.  Mountpoint volumes will be 1G by default)
    $createMountpointRoot = $true
    
    # Mountpoint Root
    $dbmproot = "M:\Exchange"
    $dbRootDrive = "M:"
 
##########################################################################################
##########################################################################################
# DO NOT EDIT BELOW THIS LINE !
##########################################################################################
##########################################################################################
 
 
# Creates volume with specified name and size using connection instantiated on script launch
function CreateVolume
{
    param
    (
        [string]     $VolumeName,
        [string]     $VolumeSize,
        [string]     $MPRoot,
        [string]     $SCDiskFolder,
        [bool]         $IsMountPoint
    )
 
    Write-Output "Creating new volume: $volumename..."
    if($useCustomDiskFolders -eq $true)
    {$scvolume = New-SCVolume -Name $VolumeName -Size $VolumeSize -ParentFolder $SCParentFolderName -StorageType $SCDiskFolder;}
    else
    {$scvolume = New-SCVolume -Name $VolumeName -Size $VolumeSize -ParentFolder $SCParentFolderName;}
 
    # Maps volume previously created and returned from CreateVolume function
    Write-Output "Mapping new volume $volumename to $servername..."
    
    # Map Volume (if multiple HBA ports are server will be used, make sure that MPIO is installed on server and remove -SinglePath switch from next line
    New-SCVolumeMap -VolumeIndex $scvolume.Index -ServerIndex $scserver.Index -SinglePath
 
    # Rescan Server
    Write-Output "Rescanning server for new volume..."
    Rescan-DiskDevice -Server $ServerName -RescanDelay 5
 
    # Issue Drive Letter / Mount Point
    Write-Output "Creating access path for new volume..."
    $device = Get-DiskDevice -SerialNumber $scvolume.SerialNumber
    
    # Check to see if the device is there yet after initial rescan
    if($device -eq $null)
    {
        # Device is still null, so let's perform up to 10 rescans before we move on
        $scancount = 0
        
        do
        {
            # Rescan the disk
            Write-Output "Rescanning server for new volume..."
            Rescan-DiskDevice -Server $ServerName -RescanDelay 5
            $scancount ++
            
            # Try getting the device again
            $device = Get-DiskDevice -SerialNumber $scvolume.SerialNumber
        }
        until($device -ne $null -or $scancount -eq 10)
    }
    
    # Set variable (this is only used if this is a drive letter mount)
    $finalpath = $MPRoot
    
    # Set full mountpoint path (create path if it doesn't exist)
    if($IsMountPoint -eq $true)
    {
        $finalpath = "$MPRoot\$VolumeName"
        
        # Check to make sure the full mountpoint path acutually exists, otherwise create it
        if (!(Test-Path -path "$finalpath\"))
        {
            New-Item "$finalpath\" -type directory
        }
    }
    
    Write-Output "Onlining Disk and setting access path to $finalpath..."
 
    # Finish creation of mountpoint/drive access
    Set-DiskDevice -SerialNumber $device.SerialNumber -Online
    Set-DiskDevice -SerialNumber $device.SerialNumber -ReadOnly:$false 
    $newvol = New-Volume -DeviceName $device.DeviceName -Server $ServerName -Label $VolumeName -AccessPath $finalpath
    
    # Null out device
    $device = $null
}
 
function LoadSnapins
{
    # Load Exchange Management Shell & Compellent Storage Center Snapins (if not already)
     $LoadedSnapins = Get-PSSnapin;
    $SnapinsToLoad = "Compellent.StorageCenter.Scripting", "Microsoft.Exchange.Management.PowerShell.E2010"
    
    "Adding PowerShell Snapins..."
 
    foreach($snapin in $SnapinsToLoad)
    {
        if (get-pssnapin $snapin -ea "silentlycontinue") 
        {
            write-host "$snapin is already loaded."
        }
        elseif (get-pssnapin $snapin -registered -ea "silentlycontinue") 
        {
            Add-PSSnapin $snapin
            Write-Host "$snapin is now loaded."
        }
        else 
        {
            write-host "PSSnapin $snapin not found" -foregroundcolor Red
        }
    }
}
 
#############################
# START SCRIPT
#############################
 
$started = Get-Date
 
#Load Requested Snapins
LoadSnapins
 
# Initialize Connection for Storage Center
#$pass = Read-Host -AsSecureString -Prompt "Please provide the Storage Center password for $user"
$securepass = ConvertTo-SecureString $pass -AsPlainText -Force
$connection = Get-SCConnection -HostName $schost -User $user -Password $securepass -Save $schost -Default
 
# Create new Volume Folder if it doesn't exist
$volumefolder = Get-SCVolumeFolder -Name $SCParentFolderName
if($volumefolder -eq $null)
{
    Write-Output "Creating new volume folder: $SCParentFolderName..."
    $volumefolder = New-SCVolumeFolder -Name $SCParentFolderName;
}
 
# Get server information for the server that we are mapping all of the volumes to
$scserver = Get-SCServer -Name $ServerName
 
# Create New Mount Point Volumes for database and logs (if requested)
if($createMountpointRoot -eq $true)
{
    CreateVolume "$ServerName-Exchange-MP" "1G" $dbRootDrive $dbDiskFolder $false
}
 
# Reset counters
$dbcount = 1
 
# Loop through total amount of databases for the server
do
{
    CreateVolume "$ServerName-DB$dbcount" $dbsize $dbmproot $dbDiskFolder $true
    
    "Creating mailbox database in Exchange 2010..."
    New-MailboxDatabase -Server $ServerName -Name "$ServerName-DB$dbcount" -EdbFilePath "$dbmproot\$ServerName-DB$dbcount\$ServerName-DB$dbcount.edb" -LogFolderPath "$dbmproot\$ServerName-DB$dbcount\Logs\"
    
    "Mounting new mailbox database..."
    Mount-Database -Identity "$ServerName-DB$dbcount"
    
    $dbcount ++ 
}
until($dbcount -eq $dbtotal + 1)
 
 
# Complete!
$ended = Get-Date
Write-Output "Volume Creation Complete!"
Write-Output "Started: $started"
Write-Output "Finished: $ended"
 
#############################
# END SCRIPT
#############################

There are a number of areas in which this script can be improved and that I will continue to work on. 

Exception handling is very important.  Understanding how your code could react in particular scenarios is difficult, but you don’t want your script to bomb out every time you run it either.  I’ve build quite a bit of exception handling into the mapping and mounting portions of the script, but this can always be reworked to be improved.