Zsoldier
Expert
Expert

Omitting VM's associated with DRS Rules

Jump to solution

I'm so freakin' close, I can smell it, but don't think my desk can handle anymore head banging.

$Cluster = Get-Cluster ClusterName

$DRS = $Cluster | get-drsrule | % {$_.VMIds}

$VMS = $Cluster | Get-VM | where {$_.Id -notmatch $DRS}

I've tried -notcontains, -inotcontains, inotmatch, etc. to no avail. Any help would be appreciated. Can't figure out how to get powershell to handle the array.

P.S. - "$VMS = $Cluster | Get-VM | where {$_.Id -notmatch $DRS[0]}" does work.

K. Chris Nakagaki (Zsoldier)

http://tech.zsoldier.com

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
sherold
Expert
Expert

Original Post removed from my own stupidity...

When doing -notcontains, are you listing the source first?

$VMS = $Cluster | Get-VM | where {$DRS -notcontains $_.Id}

-Scott

________________________

http://www.vmguru.com

http://www.thevesi.org

-Scott ________________________ http://www.vmguru.com http://www.thevesi.org

View solution in original post

0 Kudos
2 Replies
sherold
Expert
Expert

Original Post removed from my own stupidity...

When doing -notcontains, are you listing the source first?

$VMS = $Cluster | Get-VM | where {$DRS -notcontains $_.Id}

-Scott

________________________

http://www.vmguru.com

http://www.thevesi.org

-Scott ________________________ http://www.vmguru.com http://www.thevesi.org
0 Kudos
Zsoldier
Expert
Expert

I have a copy of the original post if you would like me to repost. LOL. That worked, thank you. Knew it was something stupid.

K. Chris Nakagaki (Zsoldier)

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
0 Kudos