How to setup a Powershell Environment to manage VMware

  1. Make sure .NET Framework 4.5 is installed (HERE)
  2. Make sure that Powershell 3.0 is installed (do not use 4.0 as it breaks add-ins) (HERE)
  3. Install vSphere PowerCLi (HERE)
  4. open PS and run:  Set-ExecutionPolicy -ExecutionPolicy unrestricted
  5. Close and reopen PS and create a new profile by running:  New-item –type file –force $profile
  6. Run the following:  Notepad $profile
  7. Paste the following into the file:
    1. Add-PSSnapin VMware.VimAutomation.Core
      Add-PSSnapin VMware.VimAutomation.Vds
      Add-PSSnapin VMware.VimAutomation.License
      Add-PSSnapin VMware.DeployAutomation
      Add-PSSnapin VMware.ImageBuilder
      Add-PSSnapin VMware.VimAutomation.Cloud
  8. Save the PS1 file on your desktop and open a session via the shortcut.


Continue Reading

A nice Slash and Burn script for vCD

WARNING!!! This will delete ALL VMs in your vCD!!!!!

Connect to your vCD with “Connect-CIServer ” and run the following:

Stop-CIVApp * -Confirm:$false
Remove-CIVApp * -Confirm:$false
sleep 5
Remove-OrgNetwork * -Confirm:$false

Then manually delete any gateway devices and then run the following to clean up all the orgs:

Set-OrgVdc -Enabled:$false
remove-OrgVdc -Confirm:$false
Set-Org -Enabled:$false 
remove-Org -Confirm:$false

Big thanks to my colleague Grant Voss for this awesome little cleanup script.

Continue Reading

Using PowerCLI To Answer Virtual Machine Message Questions









The Virtual Machine Message I’m faced with deals with the relocation of the VM.  Via the vSphere Client, my possible choices to answer the question are “Cancel”, “I moved it”, or “I copied it”.  I don’t have the patience or desire to mouse through this hundreds of times.







I want to provide the same answer, “I moved it”, for every VM in inventory which has this question.  The script to accomplish this is fairly simple, even by my standards.  Once the PowerCLI connection is established to the vCenter Server or ESX(i) host, it’s a one-liner.  Following is the PowerShell script which gets the job done for my situation:

Connect-VIServer vc501.boche.lab
Get-VM | Get-VMQuestion | Set-VMQuestion -Option “I moved it” -Confirm:$false

Note that there are different types of Virtual Machine Message questions which will yield a different set of possible answers.  Be sure to query a VM having a question via PowerCLI for the possible answers to that question.  Get-VM | Get-VMQuestion -full should do it.  Once the possible answers are revealed, use Set-VMQuestion -Option to provide an answer.

Also note the script above will cycle through all VMs in inventory, and for those having a question, it will provide the same response for each VM.  Thus the assumption is made that all VMs with pending questions have the same question being asked.  To respond to explicit question types or to filter the VMs being looped through, the script would need to be refined.

For more information on the Get-VMQuestion or Set-VMQuestion PowerCLI cmdlets, use Get-Help Get-VMQuestion -full or Set-Help Get-VMQuestion -full respectively.

Thank you to Jason Boche for this article

Continue Reading