Skip to content

Instantly share code, notes, and snippets.

@mavericksevmont
Last active September 3, 2018 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mavericksevmont/cef994a930d4c5ab354e3daf501e182f to your computer and use it in GitHub Desktop.
Save mavericksevmont/cef994a930d4c5ab354e3daf501e182f to your computer and use it in GitHub Desktop.
Blog Response: Using PowerShell To Get Physical Disk Info On A Dell Server
# This script is derived from:
# https://tech.mavericksevmont.com/blog/blog-response-using-powershell-to-get-physical-disk-info-on-a-dell-server
# Name: Posh-OMRemote.ps1
# Created by: Erick Sevilla (Maverick Sevmont)
# https://tech.mavericksevmont.com/blog/
$User = 'Contoso\Maverick1' # User variable, your user goes here
$Password = 'MyP@22w0rd' # Password variable, your password goes here
$Hostname = '192.168.77.1' # 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