Last active
August 29, 2015 14:06
-
-
Save fr0gger03/ab5eced3c44f56cf611f to your computer and use it in GitHub Desktop.
PowerCLI: script to map VMFS datastore (block only) to underlying LUN using NAA ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# you must connect and authenticate to a vCenter server | |
# use Connect-VIServer to do so | |
# establish Export file name | |
$csvname = Read-Host 'Please provide the file path and name for your CSV export' | |
# Gather information on all datastores in the vCenter and enter a loop | |
get-datastore |foreach-object { | |
# Capture the name of the datastore in a variable | |
$ds=$_.Name | |
# For each datastore, get teh information on the SCSI LUN, | |
# select specific properties and export it all to the CSV file | |
# note - the "gu" command is shorthand for "get-unique" - | |
# this is necessary as datastores will be reported by multiple virtual machines | |
get-scsilun -datastore $ds | Select-Object @{n='NAA';e={$_.canonicalname}}, @{n='Datastore Name';e={$ds}} | gu | Export-CSV "c:\users\rfw614\Desktop\scsilun.csv” -NoTypeInformation –Append | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment