• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Yellow Bricks

by Duncan Epping

  • Home
  • Unexplored Territory Podcast
  • HA Deepdive
  • ESXTOP
  • Stickers/Shirts
  • Privacy Policy
  • About
  • Show Search
Hide Search

Scripting

shutdown all vm’s and ESX

Duncan Epping · Jun 16, 2008 ·

Just dropped the following short script in a topic on the VMTN Community. It shuts down every VM on the host and than the host itself, but it will enter maintenance mode first, just to be sure that no other vm’s get migrated to this host.

VMLIST=’vmware-cmd -l’
for config in ${VMLIST}
do
vmware-cmd $config stop trysoft
done
vimsh -n -e /hostsvc/maintenance_mode_enter
shutdown -h now

addition: thanks forbes for the trysoft addition.

Powershell VI Toolkit

Duncan Epping · Apr 21, 2008 ·

Today I combined a couple of Powershell scripts which as a result gives a nice html formatted file with a table. This table contains all VM’s with their VMware Tools status and version. I’ve uploaded the script here. The outcome looks like the following:

As you can see, the VMware tools status is “ok” but the versions are totally out of line. I know there are already a few tools handling this but as far as I know none of them creates a text/html output file.

Weird scripted install problems

Duncan Epping · Apr 4, 2008 ·

Today I was testing a scripted installation for a customer. All day long I had weird problems with the script. But whenever I reviewed my script their seemed to be nothing wrong with it. I wrote the scripts with Notepad++ and double checked them with vi and nano. You can imagine I almost threw my laptop out the window of sheer frustration. Notepad++ has a function called “convert to unix format” and although I could not find any weird characters, returns of whatsoever… it did solve my problem. After having a closer look at Notepad++ it seems like there’s a setting to avoid this behaviour:

I should have known it isn’t a good idea to edit linux script files on a Windows host, if only VMware would release a linux version of the VirtualCenter client…

VI Powershell: Creating a PSDrive to browse your inventory

Duncan Epping · Mar 26, 2008 ·

Just stumbled upon this cool article about mounting your VI inventory as a drive via Powershell:

source – Hal Rottenberg aka halr9000:

  1. Establish a connection to your the server using the Get-VIServer command:
    Get-VIServer -Server
    


    for example,

    Get-VIServer -Server 192.168.10.10
    


    When prompted, provide the administrator’s username and password to authenticate access on the server.

  2. Get the root folder of the server:
    $root = Get-Folder -NoRecursion
    
  3. Create a PowerShell drive named VI, based on the server root folder. You can use the built-in New-psDrive cmdlet.
    New-PSDrive -Location $root -Name vi -PSProvider VimInventory -Root '\' 


    In this release, a single backslash is the required value for the -Root parameter.

  4. Access the new drive by typing the following command:
    cd vi:
    


    To list the drive content, use Get-ChildItem or its alias Dir.

  5. Navigate through your server inventory using the cd command with the full path to the host. For a fictional VI inventory it may looks like the following:
    cd Folder01\DataCenter01\host\Web\LiveHost01
    

Powershell Toolkit beta coming up and VMworld lab PDF!

Duncan Epping · Mar 10, 2008 ·

Eric Sloof just pointed us out to the Blog on the VMware website about the upcoming Powershell Toolkit Beta. I have been playing around with this toolkit for a while but had a hard time figuring out how to actually make useful scripts. The PDF that was also released has some cool examples of useful scripts for instance these:

Change the number of virtual CPUs configured for “Email VM 1” from 1 to 2:
get-vm “Email VM 1 User N” | `
set-vm –numcpu 2

Read the last 10 lines of the hostd log file from ESX1:
(get-log –host (get-vmhost esx1) `
hostd).Entries[-10..-1]

Identify which VMs have network adapters that are not automatically connected:
get-vm | where { `
$_ | get-networkadapter | where { `
$_.ConnectionState.StartConnected -eq 0 `
} `
}

Cool stuff!

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 14
  • Page 15
  • Page 16
  • Page 17
  • Page 18
  • Go to Next Page »

Primary Sidebar

About the Author

Duncan Epping is a Chief Technologist and Distinguished Engineering Architect at Broadcom. Besides writing on Yellow-Bricks, Duncan is the co-author of the vSAN Deep Dive and the vSphere Clustering Deep Dive book series. Duncan is also the host of the Unexplored Territory Podcast.

Follow Us

  • X
  • Spotify
  • RSS Feed
  • LinkedIn

Recommended Book(s)

Advertisements




Copyright Yellow-Bricks.com © 2025 · Log in