Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Blog Response: Using PowerShell To Get Physical Disk Info On A Dell Server
# This script is derived from:
# Name: Posh-OMRemote.ps1
# Created by: Erick Sevilla (Maverick Sevmont)
$User = 'Contoso\Maverick1' # User variable, your user goes here
$Password = 'MyP@22w0rd' # Password variable, your password goes here
$Hostname = '' # Hostname variable, the remote Dell server you'll like to query goes here
# Run omremote, collect the disk info loot and store it in a variable
$OMremoteResults = & "C:\temp\omremote\omremote.exe" -user="$User" -pswd="$Password" -com=wmi "$Hostname" omreport storage pdisk controller=0
# Rejoice on raw regex rampage magical mistery macaroni madness
[regex]$RegexCode = 'ID\s*:\s(?<ID>\d+:\d+:\d+)\s*Status\s*:\s(?<Status>\w+)\s*Name\s*:\s(?<Name>\w+\s\w+\s\d+:\d+:\d+)([\s\S]*?)(?=Failure)Failure\sPredicted\s*:\s(?<FailurePredicted>\w+)([\s\S]*?)(?=Serial)Serial\sNo\.\s*:\s(?<SerialNumber>\w+)'
$RegexParsing = ([regex]::Matches($OMremoteResults,$RegexCode)) # Invoking Regex .NET class
# Parse values as per regex group names and turn them into precious Objects
$RPtoObjects = $RegexParsing | foreach {new-object PSObject -Property @{Hostname=($Hostname);ID=($_.Groups["ID"].value); Status=($_.Groups["Status"].value);Name=($_.Groups["Name"].value);FailurePredicted=($_.Groups["FailurePredicted"].value);SerialNumber=($_.Groups["SerialNumber"].value)}}
# Make it look purty
$RPtoObjects | Format-Table Hostname,Name,ID,Status,FailurePredicted,SerialNumber -AutoSize -Wrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.