Hi all
I am using this command to rescan all host HBAs
get-vmhost | Get-VMHostStorage -RescanAllHBA
just one question does this scan with the "Scan for New VMFS Volume" ticked ???
I dont want to scan for VMFS volume !!
Cheers
This should only scan for new storage devices.
For new VMFS file systems you have to add the parameter -RescanVmfs.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This should only scan for new storage devices.
For new VMFS file systems you have to add the parameter -RescanVmfs.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Great!!!
LucD,
How do you isolate the scan to just host, cluster or datacenter.
Thanks
This cmdlet operates specifically on a host's resource--the storage adapter. Therefore, you cannot manipulate its effects in terms of cluster or datacenter, not directly. So, you'll always be using Get-VMHost right before the Get-VMHostStorage cmdlet. It is easy to change what hosts are affected, though. e.g.
get-vmhost server1 | get-vmhoststorage # only affects server1
get-vmhost | get-vmhoststorage # affects all host servers
get-vmhost server2,server3,server6 | get-vmhoststorage # acts on specified servers
get-cluster cluster1 | get-vmhost | get-vmhoststorage # operates on all hosts in cluster1
get-datacenter dc2,dc3 | get-vmhost | get-vmhoststorage # operates on all hosts in specified datacenters
[PowerShell MVP|https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], VI Toolkit forum moderator
Author of the upcoming book: Managing VMware Infrastructure with PowerShell
Co-Host, PowerScripting Podcast (http://powerscripting.net)
Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org
Message was edited by: halr9000 -- oops hit submit too quickly
Thanks halr9000. Appreciate it. BTW, when will your book be available.
So that's what i was getting messed up with since when i did get-cluster cluster1, i did not followup with get-vmhost. :smileyshocked:
Thanks again.
Looking like February.
[PowerShell MVP|https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], VI Toolkit forum moderator
Author of the upcoming book: Managing VMware Infrastructure with PowerShell
Co-Host, PowerScripting Podcast (http://powerscripting.net)
Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org
looking forward to this book!!!!!!!
Hi,
I recently purchased your book and it is an excellent one. Thanks for coming up with such a nice book.
Let me come to my question now. I want the following information for all the VMhosts.
VMHostName, FilesystemName, FileSystemType, TotalCapacity, FreeCapacity, Path.
Get-VMHost | Get-VMHostStorage | select -ExpandProperty filesystem*
Name AccessMode Type Capacity Path
-
-
-
-
-
SCSI_ES... readWrite VMFS 28185722880 /vmfs/volumes/47a71aaf-80fb6ea6-0485-...
ISCSI_O... readWrite VMFS 4026531840 /vmfs/volumes/489487c9-d6130e02-8908-...
SCSI_ES... readWrite VMFS 73282879488 /vmfs/volumes/48933a93-0f7f69f4-312e-...
How do I get the Free Capacity for all the above ?
Thanks
-M
You can try this:
$VMHosts = Get-VMHost $Datastores = $VMHosts | Get-Datastore $VMHostStorage = $VMHosts | ` Get-VMHostStorage | ` Select-Object -expandProperty FileSystemVolumeInfo | ` ForEach-Object { $VMHostStorageName = $_.Name Add-Member -InputObject $_ -MemberType NoteProperty -Name FreeSpaceMB -Value ($Datastores | Where-Object {$_.Name -eq $VMHostStorageName}).FreeSpaceMB -PassThru } $VMHostStorage | Format-Table -property Name,AccessMode,Type,Capacity,FreeSpaceMB,Path -AutoSize
Robert
Thanks MUCH Robert.
I will test it and come back. In the meanwhile, when I look at it, the output of the code will have only the following.
Name,AccessMode,Type,Capacity,FreeSpaceMB,Path
where Name indicates VMFS Volume Name...right? How do I get the VMHost name included in the outout?
VMhostName, Name, AccessMode, Type, Capacity, FreeSpaceMB, Path
Would the below code get me <code>VMhostName also?
-
$VMHosts = Get-VMHost
$Datastores = $VMHosts | Get-Datastore
$VMHostStorage = $VMHosts | `
Get-VMHostStorage | `
Select-Object -expandProperty FileSystemVolumeInfo | `
ForEach-Object $VMHostName = $VMHosts.Name
$VMHostStorageName = $_.Name
Add-Member -InputObject $_ -MemberType NoteProperty -Name FreeSpaceMB -Value ($Datastores | Where-Object {$_.Name -eq $VMHostStorageName}).FreeSpaceMB -PassThru
}
$VMHostStorage | Format-Table -property </code>$VMHostName, Name,AccessMode,Type,Capacity,FreeSpaceMB,Path -AutoSize
-
Thanks
-M
Message was edited by: GoldenArm
To get the hostname also you have to change some more things:
$VMHosts = Get-VMHost $Datastores = $VMHosts | Get-Datastore $VMHostStorage = $VMHosts | ForEach-Object { $VMHost = $_.Name $_ | Get-VMHostStorage | ` Select-Object -expandProperty FileSystemVolumeInfo | ` ForEach-Object { $VMHostStorageName = $_.Name Add-Member -InputObject $_ -MemberType NoteProperty -Name FreeSpaceMB -Value ($Datastores | Where-Object {$_.Name -eq $VMHostStorageName}).FreeSpaceMB -PassThru | ` Add-Member -MemberType NoteProperty -Name HostName -Value $VMHost -PassThru } } $VMHostStorage | Format-Table -property HostName,Name,AccessMode,Type,Capacity,FreeSpaceMB,Path -AutoSize
Robert
Thanks MUCH Robert.
HI robert,
I am looking for a script that would get me the following :
VMname, VMDKFilename, VMDKFileSizeGB, VMFS
The below code does not get me everything above...
Get-VMHost | Get-VMHostStorage | select -ExpandProperty ScsiLun
Could you help me with the code or point me in the right direction?
Thanks
-M
I won't give you the correct answer. Mostly because I do not know what you mean with the vmfs field you want in the output. But I will put you in the right direction. Notice that the CapacityGB is not exactly the same as VMDKFileSizeGB, but the values must be pretty close if you use thick disks. For thin disks the values could be quit different.
Get-VM | ForEach-Object { $VMName = $_.Name $_ | Get-HardDisk | ForEach-Object { $Report = "" | select-Object -property VMName,VMDKFilename,CapacityGB $Report.VMName = $VMName $Report.VMDKFilename = $_.Filename $Report.CapacityGB = $_.CapacityKB/1MB Write-Output $Report } }
Robert
Thanks Robert. What I meant by VMFSName was I wanted all of the VMFS names on which these individual VMDKs are created for the each of the Guest OSes.
-M
In my script you get the names of the VMFS datastore as the first part of the VMDKFilename field. If you want to get only the VMFS datastore name, you can use the split method of the string type. Like in:
"a b c".Split(" ")[0]
To get the datastore in a seperate field my script will change to:
Get-VM | ForEach-Object { $VMName = $_.Name $_ | Get-HardDisk | ForEach-Object { $Report = "" | select-Object -property VMName,Datastore,VMDKFilename,CapacityGB $Report.VMName = $VMName $Report.Datastore = $_.FileName.Split(" ")[0].Trim("") $Report.VMDKFilename = $_.FileName.Split(" ")[1] $Report.CapacityGB = $_.CapacityKB/1MB Write-Output $Report } }
Robert
Thanks MUCH Robert.
Hi Robert,
In the above script, the CapacityGB is VMDKFile's capacity or DataStore's capacity ?
Basically, I am looking for a script that would get me the following
#----
VM_Name,
FileSystems_On_Guest_OSes,
FileSystem_TotalSize_GB,
FileSystem_UsedSize_GB,
FileSystem_FreeSize_GB,
Mapping_To_VMDKFile,
VMDKFile_VMFSName,
VVMFSName_To_SANVendorName
#----
Also, I found a script http://www.peetersonline.nl/index.php/vmware/get-vmware-disk-usage-with-powershell/ taht woudl would perfectly suit my need but it errorrs out.
Any help would be greatly appreciated.
Thanks
_M