VMware Cloud Community
arbelac
Contributor
Contributor

Find VMs with Dynamic Disks On Your VMWare Cluster

Hi Guys,

I had been looking for a script for a while that would interrogate my VMWare ESX clusters and report back with a list of virtual machines running with dynamic disk.

BTW , I am speaking for Windows Guest VMs. not VMWare level.

I am trying to use invoke-vmscript to get the dynamics disk informations of multiple VM's. But no luck.

Here is my code so far: 

$outputFile = "C:\Temp\FetchVmInfo\Vminfo.csv"

$VCenterlist = Get-Content C:\Temp\FetchVmInfo\VCenterlist.txt

"Connecting vCenter servers ..."

Connect-VIServer $VCenterlist

"Getting VM(s). Be patient, this can take some time ..."

$VMsWithPower = Get-VM | ? {($_.GuestId -match "Windows") -and ($_.powerstate -eq "PoweredOn")}

foreach ($vm in $VMsWithPower) {

if ( $null -eq ( Get-WmiObject Win32_DiskPartition -filter "Type='Logical Disk Manager'" -ComputerName $vm) ) {

                Write-host  "Dynamic disk not found (What's OK!)"

            } else {

                Write-host "Oh no! Dynamic disk FOUND"

Add-Content -Path $outputFile -Value "Hostname: $($CurrentServer)"

            }

}

thanks,

0 Kudos
2 Replies
LucD
Leadership
Leadership

What goes wrong when you use Invoke-VMScript to run that Get-WmiObject  line inside the guest OS?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
arbelac
Contributor
Contributor

My question is : I was stucking about invoke-vmscript. How can I integrate invoke-vmscript inside of  my script ?

0 Kudos