Looking for a script that would move a list of datastores (one at a time) into an SDRS cluster, put the datastore into maintenane mode to vacate it, and continue until list is complete.
Anyone have something similar that they have used ? We have a script to move VMs across datastores but in this instance we must use SDRS maintenance mode because of the contents of them.
Any help is appreciated
Thanks all
Not sure how you are going to place all datastores in the datastorecluster in maintenance mode.
On the last datastore, where will the VMs be moved to?
In any case, you can create a DSC, add datastores and place a datastore in SDRS maintenance mode with regular PowerCLI cmdlets.
See this short snippet
$datacenterName = 'MyDC'
$dsNames = 'DS1','DS2'
$dc = Get-Datacenter -Name $datacenterName
$dsc = New-DatastoreCluster -Name TempDSC -Location $dc
Get-Datastore -Name $dsNames | Move-Datastore -Destination $dsc
Get-Datastore -Name $dsNames |
Select -First 1 |
Set-Datastore -MaintenanceMode:$true -EvacuateAutomatically -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Not sure how you are going to place all datastores in the datastorecluster in maintenance mode.
On the last datastore, where will the VMs be moved to?
In any case, you can create a DSC, add datastores and place a datastore in SDRS maintenance mode with regular PowerCLI cmdlets.
See this short snippet
$datacenterName = 'MyDC'
$dsNames = 'DS1','DS2'
$dc = Get-Datacenter -Name $datacenterName
$dsc = New-DatastoreCluster -Name TempDSC -Location $dc
Get-Datastore -Name $dsNames | Move-Datastore -Destination $dsc
Get-Datastore -Name $dsNames |
Select -First 1 |
Set-Datastore -MaintenanceMode:$true -EvacuateAutomatically -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD..
For more clarity we have SDRS clusters that were running all vmfs5 datastores. We have provisioned new vmfs6 datastores into said clusters and removed all the older vmfs5 ones. The goal is to move one vmfs5 datastore into the sdrs cluster which now has a bunch of new vmfs6 datastores, place it in maintenance and vacate it so the data ends up on the new vmfs6 datastores. That is the reason for doing one at a time so we do not move data amongst the older vmfs5 datastores. The end result is all our data that we cannot move via our normal svmotion scripts will be on our newly provisioned vmfs6 datastores.
Hope this helps .
I will see if i can tweak what you provided to make it work for my needs.
Ok, got it.
Let me know if you can get it to work.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Looks like when i populate more than one Datastore name for the variable $dsNames it only works on the first and fails on the remainder. It moves them all into the SDRS at once instead of serially which may be part of the issue.
It works great for single Datastores
You could handle that by ysing a ForEach loop, handle one datastore at the time.
Place it in maintenance mode, wait till all VMs have been svMotioned from the datastore, then continue with the next datastore.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Something like this?
$dsNames = 'DS1','DS2'
$dscName = 'DSC'
$dsc = Get-DatastoreCluster -Name $dscName
foreach($ds in Get-Datastore -Name $dsNames){
Move-Datastore -Datastore $ds -Destination $dsc
Set-Datastore -Datastore $ds -MaintenanceMode:$true -EvacuateAutomatically -Confirm:$false
while((Get-VM -Datastore $ds).Count -ne 0){
sleep 5
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Testing now, stay tuned
Appreciate the help and effort on this
Hi,
will this also evacuate off Templates?
Thanks,
Joe
I'm afraid not.
One way is to convert the templates temporarily to VMs, before activating SDRS maintenance.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference