Saturday, March 5, 2016

VMware PowerCLI find vm is present of not in the inventory after comparing with .csv list

##############################################################################
#create a file named file.csv and format it as below
#
#Name
#vm1
#vm2
#vm3
#
#
##############################################################################
$dd=Import-Csv c:\me\file.csv
foreach($vl in $dd)
{
$vv=""
   
            $vv=get-vm -name $vl.name -ErrorAction SilentlyContinue
         
            if($vv.name -eq $vl.name)
                {
                write-host "found :" $vl.name
                }
                else
                {
                write-host "VM Not Found :" $vl.name
                }
                $vv=""
   
 
}


No comments:

Post a Comment

Thanks for showing interest in tech-jockey.

Content of this blog has been moved to GITHUB

Looking at current trends and to make my content more reachable to people, I am moving all the content of my blog https://tech-jockey.blogsp...