Skip to main content
Home
badllama.com
  • Search
  • Log In

PowerCLI commands

cpeters's picture

Fri, 09/27/2013 - 09:40 by cpeters

Connect to a vcenter server

  1. Connect your vsphere client
  2. Open PowerCLI
  3. Connect-VIServer -Server [servername] -Protocol https -User [username] -Password [password]

Retrieve all the IPs of all the VMs

  1. Create a new text document
  2. rename the document to FindIPs.ps1
  3. insert the following text
  4. $vms = Get-VM
    foreach($vm in $vms){
      
      $vmIP = $vm.Guest.IPAddress
      foreach($ip in $vmIP){
         $A = $vm.Name + ", " + $IP
         Write-Host $A
         Add-Content .\IP.List.txt $A
      }
    }
    
  5. execute the script in PowerCLI
Powered by Backdrop CMS