PowerCLI script to get NAA and Datastore name of all storage on ESX Server

Use the following script to get a list of Datastores, their respective capacities and their corresponding NAAs on an ESX Server:

$esxName = "esx01.vi.local"

Connect-VIServer vs01.vi.local

New-VIProperty -Name lunDatastoreName -ObjectType ScsiLun -Value {

    $ds = $lun.VMHost.ExtensionData.Datastore | %{Get-View $_} | `
        where {$_.Summary.Type -eq "VMFS" -and
            ($_.Info.Vmfs.Extent | where {$_.DiskName -eq $lun.CanonicalName})}
} -Force | Out-Null

Get-VMHost -Name $esxName | Get-ScsiLun | Select CanonicalName, CapacityMB, lunDatastoreName

To export the results to a CSV file run same script adding the following to the end of the last line:

 | Export-csv C:\DatastoreInfo.csv

I can’t remember where I got this script from, whoever it was, I thank-you sincerely! The Get-ScsiLun command line reference can be found here.

Credit to Whowe who added his method in the comments below which worked perfectly. His script code is directly below, I have added some connection parameters to show you how I would use it to get datastore info:

$esxName = "esx01.vi.local"

Connect-VIServer vs01.vi.local

Get-VMHost -Name $esxName | Get-Datastore |

Where-Object {$_.ExtensionData.Info.GetType().Name -eq "VmfsDatastoreInfo"} |

ForEach-Object {

if ($_)


$Datastore = $_

$Datastore.ExtensionData.Info.Vmfs.Extent |

Select-Object -Property @{Name="Name";Expression={$Datastore.Name}},




The output from the script is below which shows NAA as well as Datastore info (but not capacity):

[vSphere PowerCLI] C:\Admin> .\GetDSInfo.ps1

Name                           Port  User
----                           ----  ----
vs01.vi.local                  443   DOMAIN\admin

Name     : datastore-1-R1
DiskName : naa.6848f690ec8be200191117982eb0b641

Name     : datastore-2-R5
DiskName : naa.60000970000295800173533030384646

Hope this benefits someone out there and thanks to Whowe for his contribution!

Install IIS 7.5 & FTP Server from the command line or script

If you have to install IIS multiple times on multiple systems, using the GUI to do it becomes a  real chore. An easier way is to install it from a script or from the command line.

This page has more details about installing IIS 7.5 from the command line. I have added some options in the command to install the FTP Server also, see below:

CMD /C START /w PKGMGR.EXE /l:log.etw /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-CGI;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-Security;IIS-BasicAuthentication;IIS-WindowsAuthentication;IIS-URLAuthorization;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;IIS-LegacyScripts;IIS-LegacySnapIn;IIS-FTPServer;IIS-FTPSvc;IIS-FTPExtensibility;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;IIS-ManagementService

Running the above command in the CMD shell will install the Web Server Role on Server 2008 R2 (IIS 7.5). If you do not require all of the modules, remove the ones you don’t need from the command.

To install from a script, dump the command above into a batch file and execute it.