Hello guys, I hope you are doing well.
I have some issues with one of the codes. I'm trying to get a vm inventory with the associated storage class and the provisioned space from that storage class.
I'm using a single storageclass category and different tags"( based on storage class, Bronze, platinum ,,,. I'm only tagging the datastores.
When I execute the single line get-vm vm11 |Get-Datastore |Get-TagAssignment I get the desired output, but with the code below, I'm always getting " com.vmware.cis.tagging.TagAssociationModel" as output 😞
At the end , the goal is to find a way to get the provisioned space for a VM by storageClass and not having a line per vmdk. (hdsizeGB)
Thank you
####
Get-VM -PipelineVariable vm |
ForEach-Object {
Get-HardDisk -VM $vm |
ForEach-Object -Process {
New-Object -TypeName PSObject -Property ([ordered]@{
VM = $vm.Name
StorageClass = get-vm $vm |Get-Datastore |Get-TagAssignment
NumCpu = $vm.NumCpu
MemoryGB = $vm.MemoryGB
HDName = $_.Name
HDFilename = $_.Filename
HDSizeGB = $_.CapacityGB
PowerState = $vm.powerstate
})
}
}
This should give the GB used per Datastore (and the Tag name).
Get-VM -PipelineVariable vm |
ForEach-Object {
Get-HardDisk -VM $vm |
Group-Object -Property {$_.Filename.Split(']')[0].TrimStart('[')} |
ForEach-Object -Process {
New-Object -TypeName PSObject -Property ([ordered]@{
VM = $vm.Name
Datastore = $_.Name
StorageClass = (Get-Datastore -Name $_.Name | Get-TagAssignment).Tag.Name
NumCpu = $vm.NumCpu
MemoryGB = $vm.MemoryGB
HDSizeGB = ($_.Group | Measure-Object -Property capacityGB -Sum).Sum
PowerState = $vm.powerstate
})
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
How did you tag those datastores?
And which vSphere version are you on?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello Lucd
I'm tagging them directly via the vCenter manually based on a naming convention and the storage class one the Datastore is created the 1st time.
The thing is that i'm trying to get something like the view of storage policy on vcloud director.
On vcloud director is it easy as with the vdc concept you can get that information easily.
I'm currently using
Thank you
I've solved the com.vmware.cis.tagging.TagAssociationModel issue by adding the , get-vm vm11 |Get-Datastore |Get-TagAssignment |Select-object Tag
Now I have to figure out how to concatenate the HDSizeGB based on the tag assigned to the datastore.
for example If tag = GOLD do the total of vmdks.
Sorry but I don't see tags on datastores with the Get-TagAsignment cmdlet
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm doing basically this: In Tags & CustomAttributes
This should give the GB used per Datastore (and the Tag name).
Get-VM -PipelineVariable vm |
ForEach-Object {
Get-HardDisk -VM $vm |
Group-Object -Property {$_.Filename.Split(']')[0].TrimStart('[')} |
ForEach-Object -Process {
New-Object -TypeName PSObject -Property ([ordered]@{
VM = $vm.Name
Datastore = $_.Name
StorageClass = (Get-Datastore -Name $_.Name | Get-TagAssignment).Tag.Name
NumCpu = $vm.NumCpu
MemoryGB = $vm.MemoryGB
HDSizeGB = ($_.Group | Measure-Object -Property capacityGB -Sum).Sum
PowerState = $vm.powerstate
})
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That does the work. You're the man ^^