hello,
I hope the command and script below can help you, it's what I use.
1/ to get drs rules
----------
Get-VM |Select Name,@{N='DRSGroup';E={$script:group = Get-DrsClusterGroup -VM $_; $script:group.Name}},@{N='GroupType';E={$script:group.GroupType}}
------------------
2/ to get Vm not in DRS:
----------------------
foreach ($Cluster in Get-Cluster) {
Write-Host "`n"
Write-Host $Cluster.Name
add-content .\notindrs.txt $Cluster.Name
$ClusterVMs = ($Cluster | Get-VM)
$GroupVMs = $null
foreach ($DrsGroup in ($Cluster | Get-DrsClusterGroup)) {
$GroupVMs = $GroupVMs + $DrsGroup.Member
}
foreach ($VM in $ClusterVMs) {
if ($VM -notin $GroupVMs) {
add-content .\notindrs.txt $VM.name
Write-Host "`t" $VM.name}
}
}
---------------------
3/ to get the DRS List:
---------------
foreach ($Cluster in Get-Cluster) {
#Write-Host "`n"
#Write-Host $Cluster.Name
$ClusterVMs = ($Cluster | Get-VM)
$GroupVMs = $null
foreach ($DrsGroup in ($Cluster | Get-DrsClusterGroup)) {
#Write-Host "`t" $Cluster.Name,",",$DrsGroup,",",$DrsGroup.Member
#echo "`t" $Cluster.Name,",",$DrsGroup,",",$DrsGroup.Member >> drs.csv
add-content .\drs.txt $Cluster.Name,$DrsGroup,$DrsGroup.Member
#$result +=$Cluster.Name,",",$DrsGroup,",",$DrsGroup.Member
}
}
Write-Host $result
#add-content .\drs.txt $result
Original Message:
Sent: May 22, 2024 10:26 AM
From: VMwareGeek_
Subject: Powershell Script to export cluster DRS and HA configurations as csv file
Hi,
We have dozens of vcenters, I need a common script to use on each to get output of Cluster DRS and HA configurations to save as csv file.
Can be seperate scripts to run on Powershell by connecting to each vCenter.
I am not sure where to start.
I can describe which options need to be listed if this helps the scripting process.