Showing posts with label PowerCLI. Show all posts
Showing posts with label PowerCLI. Show all posts

Thursday, October 24, 2013

How to download a diagnostic log bundle from an ESX/ESXi host using PowerCLI

Login to desired host using PowerCLI:
Connect-VIServer -Server HostnameOrIPAddress

Download a diagnostic log bundle from host:
Get-VMHost HostNameOrIP | Get-Log -Bundle -DestinationPath c:\Storage\Location\




 

Monday, September 2, 2013

Gracefully shutdown VM using PowerCLI

This is very useful for me when I need to power off my lab at home (trying to conserver energy) :)

Prerequisites for this to work is that you have PowerCLI installed on your computer as well as vm tools installed on all vm's that you would like to utilize this on

Power off single machine:

get-vm vm-name | ShutdownVMGuest

Power off group of machines:

Create a text file with list of vm's you would like to shut down with each vm in separate line such as
vm1
vm2
vm3
Let say this file is called servers.txt and is located in c:\users\mike\desktop
First we will create variable to load servers from text files:
$servers = Get-Content -Path c:\users\mike\desktop\servers.txt
second we will use previous command to shut down group of servers in the file:
get-vm $servers | Shutdown-VMGuest

Turn on group of machines: (This please be careful with as if you try to turn on too many machines at one time you could potentially overload your ESX box)

Start-VM -VM $servers