Skip to content

Instantly share code, notes, and snippets.

@sandeep-sr
Created June 3, 2021 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandeep-sr/68e2a1dc0b04d92e8416afc30692191c to your computer and use it in GitHub Desktop.
Save sandeep-sr/68e2a1dc0b04d92e8416afc30692191c to your computer and use it in GitHub Desktop.
powercli - VM exists in a specific cluster
Get-Module -ListAvailable *vm*|Import-Module
$cred=Get-Credential
Connect-VIServer vcenter01 -Credential $cred
$vms=Get-Content C:\temp\vmcheck.txt
foreach($vm in $vms)
{
$exsists=Get-Cluster cluster02|get-vm $vm -ErrorAction SilentlyContinue
if($exsists){
Write-Output "$vm exist" }
else{
Write-Output "$vm not exists" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment