• 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

Powershell and importing .CSV files

Duncan Epping · Mar 11, 2009 ·

I’ve been playing around with powershell yesterday. We needed to create over 100 VM’s and there’s no point in doing that all by hand. The customer provided us with a .csv file that contained specific info on these VM’s. It took me a while to figure out how to read the info.csv file and how to actually use it. But as always it’s actually fairly simple and that’s why I decided to write it down:

Before we even start, the CSV should be formatted as follows:

vmname,cluster
VM001,HA-DRS-Yellow-Bricks

Read the complete csv file into a variable:

$csv_info = Import-Csv c:\scripts\info.csv

For every line in the csv variable do something:

foreach ($line in $csv_info) {
write-host " This is virtual machine $($line.vmname) on cluster $($line.cluster)"
}

This line would print something like this:

This is virtual machine VM001 on cluster HA-DRS-Yellow-Bricks

As you noticed in the example above we used $line.vmname to get the name of the VM printed and $line.cluster for the cluster name, cool huh! BTW, Alan’s quick reference guide really helped me out!

Set Disk.UseDeviceReset with powershell

Duncan Epping · Mar 9, 2009 ·

Last week the well known powershell guru Alan Renouf helped me out with a script for enabling virtualized MMU. This week I needed to set Disk.UseDeviceReset to “0” on at least 60 hosts. (Check the link for more info on why!) No point in doing it all by hand when the VI Toolkit can help you out and set this parameter for the entire environment with just one line:

Get-VMHost | Set-VMHostAdvancedConfiguration -Name Disk.UseDeviceReset -Value 0

I’m really starting to get excited about the VI Toolkit, thanks to guys like Alan and of course the VMworld VI Toolkit Lab I did a couple of weeks ago. With the quick reference guide that Alan created it’s very simple to come up with one-liners like the one above.

DEPRECATED See this article for more info.

VIMA and the UPS initiated shutdown, the “lamw” version

Duncan Epping · Feb 19, 2009 ·

I already predicted that this was bound to happen sooner or later. It only took William Lam, aka lamw, a couple of days to enhance the work that Joseph Holland did. Joseph wrote a procedure that let’s APC’s software initiate a shutdown of the VM’s and ESXi host when a power failure occurs. Joseph’s solution included a modification of ESXi which means no VMware support.

I hinted William via twitter and he came up with a perl script that uses the API to initiate the shutdown of the VM’s and the ESXi host. This script will be run on the VIMA VM. There’s no need to change the ESXi host anymore!

ghettoShutdown.pl – This script initiates the shutdown of all VM(s) within an ESX/ESXi host excluding the virtual machine that’s monitoring the UPS device and then shutdowns the host. It accepts two commandline parameters: –sleep the duration in seconds to wait after a VM has initiated the shutdown before moving onto the next VM (shutdownVM() is non-blocking function) and –ups_vm the name of the displayName of your VM that is monotiring the UPS device [more details to come later].

upsVIShutdown.pl – This script is a wrapper which will hold the configurations of the order of hosts to shutdown. It may be used inconjunction with other UPS monitoring utility, though with our example, it’ll be placed in the apccontrol script to execute upon a power interuption.

Now head over to the VMware Communities, download the script and testdrive it! Awesome work William!

New version of ESX Deployment Appliance(EDA)

Duncan Epping · Feb 14, 2009 ·

Herco van Brug aka “brugh” just released a new version of ESX Deployment Appliance(EDA), 0.87.

New in 0.87:

  • editing the order of the scriptparts
  • bulk creation and deletion of ESX hostnames/ip
  • an fs.php page that allows for small remote updates
  • ESXi support fixed again

So if you want to install your ESX hosts in a consistent way and faster than ever before, look into EDA now. If you need a guide on how to set it up take a look at Simon Long’s post on GabesVirtualWorld.com.

New VMware Healthcheck Script!

Duncan Epping · Feb 1, 2009 ·

A couple of days ago I wrote an article about a “quick migration” script by William Lam.William seems to have some spare time on his hands or works 24 hours a day cause he just finished up a Health Check script. His script can be compared to the powershell healthcheck scripts and the Service Console script.

The script reports on the following:

  • vCenter Build/Release
  • ESX/ESXi Build/Release
  • Cluster(s) Name/Statistics (Hosts,CPU and MEM availabity, HA,DRS and DPM enabled)
  • ESX/ESXi Hardware configuration (NICs/HBAs)
  • ESX/ESXi State
  • ESX/ESXi Config (WIP)
  • ESX/ESXi Datastore summary
  • Virtual Machines summary
  • VM Storage summary
  • VM Network summary
  • VM w/Snapshots
  • VM w/RDMs
  • VM w/NPIV enabled
  • VM w/connected CD-ROMs
  • VM w/connected Floppys

For more details, please take a look at the sample report located at here. There’s an extensive VMTN blog article here which contains usage information. The requirements for this script is: vCenter 2.5, ESX(i) 3.5, VI-Perl Toolkit or VIMA.

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 5
  • Page 6
  • Page 7
  • Page 8
  • Page 9
  • Interim pages omitted …
  • 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