PoshCode Archive  Artifact [5824eff477]

Artifact 5824eff477a73f70ba13dc87f623f9a7e739d539464a2520c146a6043c1e2ddb:

  • File Format-HPEVAXMLVdisk.ps1 — part of check-in [1747c8d7ad] at 2018-06-10 13:45:56 on branch trunk — This script takes the output from the “ls vdisk full xml > vdisks.xml” HP EVA/P6000 and parses it into a form that can be imported into XML for reporting purposes. (user: jgrote size: 2199)

# encoding: ascii
# api: powershell
# title: Format-HPEVAXMLVdisk
# description: This script takes the output from the “ls vdisk full xml > vdisks.xml” HP EVA/P6000 and parses it into a form that can be imported into XML for reporting purposes.
# version: 0.1
# author: jgrote
# license: CC0
# x-poshcode-id: 4790
# x-archived: 2014-01-18T11:52:35
# x-published: 2014-01-14T05:17:00
#
# Wrote this quick and dirty for a client with a really old EVA and no SMI-S interface. Proper would have been as a script cmdlet.
#
#Input File. Run "ls vdisk full xml > vdisks.xml" in HP SSSU to generate
$vdiskxmlfilepath = "vdisks.xml"

#Where to output the CSV file
$csvOutputFilepath = "vdisks.csv"

#Convert SSSU XML Output to usable objects, massaging out some bad formatting generated by HP SSSU
$vdiskxml = [xml]("<vdisks>" + (get-content $vdiskxmlfile | where {$_ -notmatch "Active information"}) + "</vdisks>")

#Collect vDisk XML Objects
$vdisks = $vdiskxml.vdisks.object

#Generate summary objects from the raw data for export to CSV. Did this with select because I'm lazy and it's fast, should have used foreach and new-object for more readable code.
$vdisksummary = $vdisks | select `
    @{Name="Name";Expression={$_.familyname}}, #Change "familyname" property to "Name"
    @{Name="DiskGroup";Expression={$_.diskgroupname.substring($_.diskgroupname.lastindexof('\')+1)}}, #Parse the diskgroupname property to return whatever is after the last slash of the string
    @{Name="Folder";Expression={$firstpass=$_.objectname.substring(0,$_.objectname.lastindexof('\'));$firstpass.substring(0,$firstpass.lastindexof('\'))}}, #Parse the path property to remove everything after the second to last slash. This is ugly I know and a regex would be better.
    @{Name="FirstPresentedHost";Expression={$_.presentations.presentation.hostname}}, #This will be blank if there are multiple
    @{Name="FirstPresentedLUN";Expression={$_.presentations.presentation.lunnumber}}, #This will be blank if there are multiple
    requestedcapacity,
    allocatedcapacity,
    redundancy,
    comments

#Export to CSV
$vdisksummary | Export-Csv $csvOutputFile -notypeinformation