VMware Cloud Community
ndraj
Contributor
Contributor
Jump to solution

Getting thick and thin info from datastore

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

0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

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

    }

}

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

2 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

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

    }

}

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
ndraj
Contributor
Contributor
Jump to solution

thanks, this script has helped me to save a lot of time.

0 Kudos