UNSOLVED

DELL-Bill Gr

updated

15 years ago

0

15687

November 21st, 2011 11:00

Powershell - Clearing Alerts

This post has been copied from the former Compellent User Forum and placed here for your reference.  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.

Clearing Alerts – Originally posted By kbailey, 05 Oct 2011

kbailey - This script will clear all alerts for a specified storage center. 

# Set the variables that are needed for the script to run

$ErrorActionPreference = "Inquire"

$compSnapinName = "Compellent.StorageCenter.PSSnapin"

$schost = Read-Host -Prompt "Please enter hostname or IP of the controller"

$scuser = Read-Host -Prompt "Please enter your username"

$scpass = Read-Host -AsSecureString -Prompt "Please enter your password"

# ****** FUNCTIONS USED IN THE MAIN SCRIPT ********

# Check that the snapin is loaded

function CheckForSnapin

{

    param([string]$snapinName)

    $SnapinLoaded = $FALSE

    $currentSnapins = $null

    $currentSnapins = Get-PSSnapin

    foreach ($snapin in $currentSnapins)

    {

        if ($snapin.Name -eq $snapinName)

        {

            $SnapinLoaded = $TRUE

        }

    }

    $SnapinLoaded

}

# ****** MAIN SCRIPT STARTS HERE ********

# Check for Snapin and load if needed

$snapinLoaded = CheckForSnapin -snapinName $compSnapinName

if ($snapinLoaded -eq $FALSE)

{

    Add-PSSnapIn $compSnapinName

    $snapinLoaded = CheckForSnapin -snapinName $compSnapinName

    if ($snapinLoaded -eq $FALSE)

    {

        Write-Host "Unable to load the Compellent PowerShell Snapin - exiting" -Fore Red

        break;

    }

}

# Connect to the Compellent controller

$connected = Get-SCConnection -HostName $schost -User $scuser -Password $scpass #-Save $schost -Default

if ($connected.Host -ne $schost)

{

    Write-Host "Unable to connect to the Compellent controller $schost as user $scuser - exiting" -Fore Red

    break;

}

Get-SCAlert -Connection $connected | Acknowledge-SCAlert -Connection $connected