Reply to Message

View discussion in a popup

Replying to:
jmajor1111
Contributor
Contributor

Script to match a VM that shows 2 datastores

been working on this for a few... err... long time. searched all over an i just can't find what i need, not complete anyway.

I have several hundred VMs that we did a svmotion from one datastore to another. about 20% of them did what is called linked-cloning and left the old datastore listed. Its not critical we fix this but we need to for future reasons and we know the easiest fix is to just create a snapshot which for whatever reason kicks the VM into realizing the old datastore isn't active.

I'm trying to write a script that would check a cluster for VMs with 2 datastores listed matching XXX1 and XXX2

here is what i have:

$vms = Get-Cluster "drscluster01" |Get-VM |Get-Datastore |where {$_.Name -match "XXX1" }|where {$_.Name -match "XXX2"}

Foreach ($Vm in $Vms) {

Write-Host "test"

}

obviously write-host "test" just tells me its found, i plan on putting in create-snapshot for it once i know it works. More importantly is I can't get them to match 1 name let alone 2.

Any help would be appreciated Smiley Happy

Reply
0 Kudos