
List VM VDIs by SR IP
Quick and dirty Powershellscript to display the mount point and network point of VDIs by Virtual machines on a specific NFS Storage IP
– you need the XenServerPSModule available on citrix downloads
– just change the first to lines to your xenserver and nfs ip and that’s is
#parameter $nfsip = "192.168.0.10" $xenserverip = "192.168.0.4" Import-Module XenServerPSModule Connect-XenServer -Url https://$xenserverip #get all pdbs linked pointing to tintri datastore $colpbd = Get-Xenpbd | where {$_.device_config.server -like $nfsip} foreach ($pbd in $colpbd){ #get all SRs pointing to tintri pbds $colsr = Get-XenSR -opaque_ref $pbd.SR.opaque_ref foreach ($sr in $colsr) { #get all VDIs on SR $colvdi = Get-XenVDI | where { $_.SR.opaque_ref -like $sr.opaque_ref} foreach ($vdi in $colvdi){ #get vbd $colvbd = Get-XenVBD | where { $_.VDI.opaque_ref -like $vdi.opaque_ref} foreach ($vbd in $colvbd){ #Show VM VDI Path $vm = Get-XenVM -Ref $vbd.vm.opaque_ref Write-Host -For DarkYellow "The VM $($vm.name_label) has VDI $($vdi.name_label) on" Write-Host "Network Path: $($pbd.device_config.server)$($pbd.device_config.serverpath)/$($sr.uuid)/$($vdi.uuid).vhd" Write-Host "XenServer Path: /var/run/sr-mount/$($sr.uuid)/$($vdi.uuid).vhd" Write-Host "------------------------------" } } } }
Hi – Great Article. But I am unable to export in CSV or Excel. I am trying to export XenVM and associated ISO.
You safe my day!
I added the follow line and my work is done:
32 write-host „VDI Object Size: $($vdi.physical_utilisation)“
Big Thanks