VMware Cloud Community
Trammell
Contributor
Contributor
Jump to solution

VM report with drives connected to SAN (clustered servers)

Creating a VM report of all our vcenters and one of the columns of data that has proved helpful in our environment is the canonicalname. When space increase request come in, we supply these to the storage team for them to increase the Lun. Then we expand the drive within the OS. Here is what I have and just can't seem to figure out how to do it.

Get-VICredentialStoreItem -File C:\Scripts\PowerCli\credentials-da1.xml | %{Connect-VIServer -Server $_.host -User $_.User -Password $_.Password}

$allhostinfo = @()


$Virtuals = Get-VM | Sort-Object -Property name


Foreach($Virtual in $Virtuals){

$list = Get-view -ViewType VirtualMachine -Filter @{"Name"="$($Virtual.Name)"} -Property name, config, guest, runtime

$allhostinfo += $list}

$Report = @()

Foreach($virtual in $allhostinfo){

$worksheet = [pscustomobject]@{

"VM Name" = $virtual.name

"Guest Host Name" = $virtual.guest.hostname

"Primary IP" = $Virtual.Guest.IPAddress

"Power State" = $virtual.Runtime.PowerState

"CPU #" = $virtual.config.Hardware.NumCPU

"Memory GB" = $virtual.config.Hardware.MemoryMB

"Configured OS" = $virtual.Config.GuestFullName

"Guest OS" = $virtual.Guest.GuestFullName

"Cluster" = (Get-VM -Name $virtual.name | Select-Object -Property Name,@{Name=’Cluster’;Expression={$_.VMHost.Parent}}).Cluster.name

"ScsiCanonicalName" = (Get-View -Id $virtual.Runtime.Host -Property Config.StorageDevice.ScsiLun).Config.StorageDevice.ScsiLun | where ??????

}

$Report += $worksheet

}

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Then you could do

"ScsiCanonicalName" = (Get-HardDisk -DiskType RawPhysical,RawVirtaul).ScsiCanonicalName

If a VM has more than 1 harddisk you can join the canonicalnames together

"ScsiCanonicalName" = (Get-HardDisk -DiskType RawPhysical,RawVirtaul).ScsiCanonicalName -join '|'


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Are these harddisks regualar VMDK ona datastore, and you want the cononicalname of the datastore?

Or are these harddisks RDMs?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Trammell
Contributor
Contributor
Jump to solution

I am looking for the LUN ID's on the virtuals which are configured for RDM.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Then you could do

"ScsiCanonicalName" = (Get-HardDisk -DiskType RawPhysical,RawVirtaul).ScsiCanonicalName

If a VM has more than 1 harddisk you can join the canonicalnames together

"ScsiCanonicalName" = (Get-HardDisk -DiskType RawPhysical,RawVirtaul).ScsiCanonicalName -join '|'


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos