I have been trying to create a power shell script and also did search to get the information of disk types in a datastore.
All iIwas able to get was to get from compute cluster or from individual VMs. Does any one here looking for similar solution or already had one. Please share or help me with one.
Thanks
You can pipe the output of the Get-Datastore cmdlet to the Get-VM cmdlet, to get only virtual machines on the datastores specified. For example, the following PowerCLI script will show you the storage format of all of the disks on the datastore named Datastore1.
Get-Datastore -Name Datastore1 -PipelineVariable Datastore |
Get-VM -PipelineVariable VM |
Get-HardDisk -PipelineVariable HardDisk |
ForEach-Object {
[pscustomobject]@{
Datastore=$Datastore.Name
VM=$VM.Name
FileName=$HardDisk.FileName
StorageFormat=$HardDisk.StorageFormat
}
}
You can pipe the output of the Get-Datastore cmdlet to the Get-VM cmdlet, to get only virtual machines on the datastores specified. For example, the following PowerCLI script will show you the storage format of all of the disks on the datastore named Datastore1.
Get-Datastore -Name Datastore1 -PipelineVariable Datastore |
Get-VM -PipelineVariable VM |
Get-HardDisk -PipelineVariable HardDisk |
ForEach-Object {
[pscustomobject]@{
Datastore=$Datastore.Name
VM=$VM.Name
FileName=$HardDisk.FileName
StorageFormat=$HardDisk.StorageFormat
}
}
thanks, this script has helped me to save a lot of time.