Hi All,
Can we validate before decommissioning or unmounting all VMFS 5.0 data store? We want to validate that no running or powered off VM's existing on the data store VMFS 5.0
We are migrating from VMFS 5.0 to VMFS 6.0 and there are tons of data store, hence want to avoid the manual check.
Thanks
vmk
Just realised I had a typo, it should be FileSystemVersion instead of FileVersion.
The updated code
Where-Object {([version]$_.FileSystemVersion).Major -eq 5} |
ForEach-Object -Process {
$vm = Get-VM -Datastore $_
if($vm.Count -eq 0){
Write-Host "No VMs on datastore $($_.Name) - Version $($_.FileVersion)"
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could do something like this
$vm = Get-VM -Datastore $dsName
if($vm.Count -eq 0){
Write-Host "No VMs on datastore $dsName"
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Can we pull at the cluster level instead of entering manually single data store at each time manually? we have around 1000 + DS.
thanks
vmk
Try like this
Get-Cluster -Name $clusterName | Get-VMHost | Get-Datastore |
ForEach-Object -Process {
$vm = Get-VM -Datastore $_
if($vm.Count -eq 0){
Write-Host "No VMs on datastore $dsName"
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Will it include local Datastore also? I want local DS also
Since we don't filter them out, yes, local datastores will be included.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Can we include the data store name along with the output because in the cluster VMFS 6.0 data store also exists and want to make sure we are deleting or unmount right the data store?
If you see out don't show data store name. Example - No VMs on VPLEX_P2CX_UD1090
PS C:\Script> .\Datastore_validation.ps1
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
No VMs on datastore
VPLEX_P2CX_UD1090 |
Try like this
Get-Cluster -Name $clusterName | Get-VMHost | Get-Datastore |
ForEach-Object -Process {
$vm = Get-VM -Datastore $_
if($vm.Count -gt 0){
Write-Host "VMs on datastore $($_.Name)"
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
And the reverse
Get-Cluster -Name $clusterName | Get-VMHost | Get-Datastore |
ForEach-Object -Process {
$vm = Get-VM -Datastore $_
if($vm.Count -eq 0){
Write-Host "No VMs on datastore $($_.Name)"
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Oops it giving VM's on the Datastore VMFS6.0 but i'm looking No NM's on VMFS 5.0 then we can easily go ahead and delete or unmount it.
LucD,
reverse one is creating confusion. Want straight forward which we can go ahead and delete it post validation
Example - No VMs on the VPLEX_P1CX_UD1090 for VMFS5.0
can we try this by giving data store name C:\temp\datastore.txt ? and get the confirmation whether any VM's running or not?
Ok, try like this.
It only looks at datastores with version 5.*
Where-Object {([version]$_.FileVersion).Major -eq 5} |
ForEach-Object -Process {
$vm = Get-VM -Datastore $_
if($vm.Count -eq 0){
Write-Host "No VMs on datastore $($_.Name) - Version $($_.FileVersion)"
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Tried but no output
Can you check if this returns anything?
Get-Datastore -Name (Get-Content -Path C:\temp\datastore.txt)
And then run
Select Name,FileVersion,@{N='V5';E={([version]$_.FileVersion).Major}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Get-Datastore -Name (Get-Content -Path C:\temp\datastore.txt) - Yes it returns datastore name and capacity and then the below output as shown in screenshot
Just realised I had a typo, it should be FileSystemVersion instead of FileVersion.
The updated code
Where-Object {([version]$_.FileSystemVersion).Major -eq 5} |
ForEach-Object -Process {
$vm = Get-VM -Datastore $_
if($vm.Count -eq 0){
Write-Host "No VMs on datastore $($_.Name) - Version $($_.FileVersion)"
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
It works this time. Just want to confirm, will it possible to confirm any leftover vmdk file or templates in the data store. I saw there are no VM's running on the data store in VM tab in VC web client
but if you browse file then you might find some leftover vmdk or zombie file or templates ( templates want to migrate to another DS before deleting DS
The Get-VM with the Datastore parameter will only return registered VMs (independent if they are powered on or not).
Unregistered VMs and orphaned VMDK files are not counted as VM.
You can run the same script for templates, just replace Get-VM with Get-Template.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you LucD.