Get-DPMDisk.ps1

#DPM #Powershell

I wanted to share this with you.  The other morning I lost half a disk array which knocked out my DPM server.  So I wanted a script that would show me the status of the DPM disks, and I wanted to run it centrally.

I came up with this: .. let me know what you think

##########################################################################################
$AppName = “Get-DPMDisk.ps1”
$AppVer  = “v1.0 [24 February 2011]”
#v1.0 24 Feb 2011 : A script it born
#
#This script gets a DPM Disk Status.  The output is Get-DPMDisk.html
#
#Written By Paul Flaherty
#blogs.flaphead.com
#
########################################################################################## $DPMServers=”ServerName”

########################################################################################## #Display script name and version
#########################################################################################
Write-host ” ” $AppName -NoNewLine -foregroundcolor Green
Write-Host “: ” $AppVer -foregroundcolor Green
Write-host “`n Run on $ServerName at $Today by $xUser” -foregroundcolor Yellow
Write-Host “|——————————————————————-|`n”

$z=”DPM DISK STATUS
Last updated: $today


Write-Host “Getting DPM Disk Status”
$FirstOne = $True
$DPMDisk = @()
ForEach($DPMServer in $DPMServers){
  IF($FirstOne){
    Write-Host “-Connecting to First DPM Server to get DPM SnapIn`n”
    Write-host $DPMServer
    $s=New-PSSession -ComputerName $DPMServer
    Invoke-Command -Session $s {Add-PsSnapin Microsoft.DataProtectionManager.PowerShell}
    Import-PSSession -Session $s -Module Microsoft.DataProtectionManager.PowerShell
    $FirstOne = $False
  }
  $DPMD = Get-DPMDisk -DPMServerName $DPMServer

  $DPMD | ForEach{
    $tmpD = “” | Select Server, Name,Status, ntdiskid, TotalCapacity, UnallocatedSpace, DiskType
    $tmpD.Server=$DPMServer
    $tmpD.Name = $_.Name
    $tmpD.ntdiskid = $_.ntdiskid
    Switch($_.Status){“0″{$tmpD.Status=”Healthy”};default{$tmpD.Status=$_.Status}}
    Switch($_.DiskType){“0″{$tmpD.DiskType=”Basic”};”1″{$tmpD.DiskType=”Dynamic”};default{$tmpD.DiskType=$_.DiskType}}
    $tmpD.TotalCapacity = [Math]::round(([int64]$_.TotalCapacity) /1GB,2)
    $tmpD.UnallocatedSpace= [Math]::round(([int64]$_.UnallocatedSpace) /1GB,2)
   $DPMDisk += $tmpD
  }
} #ForEach

$xHTML = $DPMDisk | ConvertTo-Html -head $HtmlHeader -Title “DPM Disk Status” -body $z

$xEnd = get-Date
$xHTML += “



Script Completed: $xEnd

$xHTML | out-file Get-DPMDisk.html
Exit-PsSession
##########################################################################################
#End
##########################################################################################


My Powershell Public Library: http://cid-7e65f405c984b33f.office.live.com/self.aspx/Powershell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.