Quantcast
Channel: VMware Communities : Blog List - All Communities
Viewing all articles
Browse latest Browse all 3135

Identify VMDK sharing using powercli

$
0
0

connect-viserver vcentername

$vmname=read-host -Prompt "ENter the VM Name"

 

if (get-vm $vmname -erroraction SilentlyContinue)

    {

    $vdisk=get-vm $vmname |Get-VMHardDiskDrive

 

 

    $allvms=get-vm

       

 

        foreach ($allvm in $allvms)

            {

            if ($allvm.name -ne $vmname)

                {

                $vmdiskpath=get-vm $allvm |get-harddisk

                    foreach($disk in $vdisk)

                        {

                        if ($vmdiskpath.filename -eq $disk.filename)

                            {

                            $msg="There is a VMDKS sharing with "

                            $msg2=$allvm.name

                            $fullmsg=$msg+$msg2

                            Write-Host $fullmsg -ForegroundColor DarkGreen

                            }

                        }

                }

 

            }

    }

    else

    {

    Write-Host "VM is not available in the vCenter, please check the vm name"

    }


Viewing all articles
Browse latest Browse all 3135

Trending Articles