70 lines
3.1 KiB
PowerShell
70 lines
3.1 KiB
PowerShell
$disks = Get-DatastoreCluster SQL2_A9K_General_KeepTogether | Get-Datastore | Get-vm | get-harddisk | select Parent,CapacityGB,Persistence,@{n='Datastore';e={$_.Filename.split(' ')[0]}}
|
|
$disks | where-object Datastore -notlike "*CND*" | sort-object CapacityGB -Descending
|
|
|
|
|
|
$disks | where-object Datastore -notlike "*CND*" | where-object Persistence -like "IndependentPersistent" | where-object {$_.Datastore -notlike "*171*" -or $_.Datastore -notlike "*174*" -and $_.Datastore -notlike "*175*" -and $_.Datastore -notlike "*176*" -and $_.Datastore -notlike "*177*" -and $_.Datastore -notlike "*178*" -and $_.Datastore -notlike "*185*"}
|
|
|
|
$VMSize = @()
|
|
$disks | group-object Parent | ForEach-Object {
|
|
$obj=[PSCustomObject]@{
|
|
'VM' = $_.Name;
|
|
'SizeGB' = ($_.Group | measure-object CapacityGB -sum).sum
|
|
}
|
|
$VMSize += $obj
|
|
}
|
|
#### MOVE _CND NEXT
|
|
|
|
|
|
$disks = Get-DatastoreCluster SQL2_A9K_General | Get-Datastore | Get-vm | get-harddisk | select Parent,CapacityGB,Persistence,@{n='Datastore';e={$_.Filename.split(' ')[0]}}
|
|
$disks | group-object Parent | ForEach-Object{
|
|
$_.Group | where-object Persistence -eq IndependentPersistent | sort-object CapacityGB -Descending | select -first 1
|
|
}
|
|
|
|
$disks | group-object Parent | select Name,@{n='MaxIPDiskSizeGB';e={($_.Group | Where-Object Persistence -eq IndependentPersistent | sort-object CapacityGB -Descending | select -first 1).CapacityGB}},@{n='MaxIPDiskDatastore';e={($_.Group | Where-Object Persistence -eq IndependentPersistent | sort-object CapacityGB -Descending | select -first 1).Datastore}},@{n='TotalSizeGB';e={($_.group | measure-object CapacityGB -Sum).Sum}},@{n='DatastoreCount';e={@($_.group).count }} | sort-object MaxIPDiskSizeGB -Descending | ft
|
|
|
|
|
|
|
|
|
|
$VMs = Get-DatastoreCluster SQL1_A9K_General | Get-VM
|
|
$AllDisks = $VMs | Get-HardDisk | select Parent,CapacityGB,Persistence,@{n='Datastore';e={$_.Filename.split(' ')[0]}}
|
|
|
|
$result = @()
|
|
ForEach($VM in $VMs)
|
|
{
|
|
$VMDisks = $VM | Get-HardDisk | select Parent,CapacityGB,Persistence,@{n='Datastore';e={$_.Filename.split(' ')[0]}}
|
|
If(($VMDisks | select -Unique Datastore).count -gt 1)
|
|
{
|
|
$obj=[PSCustomObject]@{
|
|
'VMName' = $VM.Name;
|
|
'SumGB' = (Get-VM $VM.Name | Get-HardDisk | measure-object CapacityGB -Sum).Sum;
|
|
}
|
|
$result += $obj
|
|
}
|
|
}
|
|
$result | sort-object SumGB -Descending
|
|
|
|
|
|
|
|
|
|
|
|
<# Manual SQL SDRS
|
|
- get amount of space required to find a home for
|
|
- find datastore with the most VMs under under 2TB
|
|
- do those VMs take up more space than desired amount?
|
|
- if yes, move VMs to other datastores
|
|
- create new object with before and after usage
|
|
- find largest VM in group, move to datastore with highest free space
|
|
- repeat until enough specified space exists
|
|
- if no, find datastore with the most free space
|
|
- create new object with before and after usage
|
|
- move the largest vm on that datastore to the datastore with the 2nd most free space
|
|
- repeat until enough specified space exists
|
|
|
|
# >
|
|
|
|
|
|
169
|
|
|
|
*Select "Change" only if changes need to go to VM admins.
|
|
|
|
*Select "Delete" to have the VM removed and permanently deleted |