Is there a script that can run and give me a list of virtual machines which have independent disks and which virtual disk in the virtual machine is set as independent. I have external backup software which does not backup up VM's which have independent disks, and so want to exclude the virtual disks in the VM's which are set to independent.
Is this possible please
Sure, try this
$report = @() Get-VM | where {$_ | Get-HardDisk | where {$_.Persistence -like "Independent*"}} | %{ $row = "" | Select VMname, HDname $row.VMname = $_.Name $row.HDname = ($_ | Get-HardDisk | where {$_.Persistence -like "Independent*"}).Name $report += $row } $report
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Some like this:
$vms=get-vm
foreach ($vm in $vms)
{
$name=$vm.name
foreach ($harddrive in $vm.harddisks)
{
$persistence=$harddrive.persistence
If ($persistence="Independant")
{
$name
}
}
}
Dammit you beat me to it 😛
Thanks for the script.
The only problem is that it only displays the hdname of the VM's which have only one disk set to independent, for example if vm1 has 3 disks and one disk is independent it displays the hdname, but if a vm2 has 3 disks as indepdendent, its displays the VM name but not anything in the hdname.
Is it possible to change the disk.
This should list all the RDM disks
$report = @() Get-VM | %{ $vm = $_ $_ | Get-HardDisk | where {$_.Persistence -like "Independent*"} | %{ $row = "" | Select VMname, HDname $row.VMname = $vm.Name $row.HDname = $_.Name $report += $row } } $report
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference