Archive

Archive for the ‘Scripting’ Category

A few basic PowerCLI oneliners.

March 12th, 2013 No comments

Some students in my classes have been recently asking me for any good PowerCLI oneliners during my ICM classes.

Here’s a list I typically share out to my students. If you’ve got any to add, feel free to leave them in the comments section. It’s nice to get a list of these things. I also recommend the PowerCLI lab over at vNugglets to anybody getting started. Matt and Allen wrote the lab for last years Demo Days VMUG event.

Do VMs have snapshots?

foreach ($snap in (Get-VM | Get-Snapshot | Where-object {$_.Created -lt ((Get-Date).AddDays(0))})){ $snap | select VM, Name, Description, SizeMB, Created }

Rescan HBA Adapters.

foreach ($esx in Get-VMhost -Location ClusterName | sort Name) { $esx | Get-VMHostStorage -RescanAllHBA -rescanVMFS -refresh }

Add Port Group “VLAN 500” with VLAN tag 500 to vSwitch1 on all hosts in a Cluster

foreach ($esx in Get-VMHost -Location ClusterName | Sort-Object Name) { $esx | Get-VirtualSwitch -Name vSwitch1 | New-VirtualPortGroup -Name “VLAN500″ -VlanId 500 }

vMotion and Storage vMotion

Get VM Information, Cluster, Host, Datastore

Get-VM | Select Name, @{N=”Cluster”;E={Get-Cluster -VM $_}},@{N=”ESX Host”;E={Get-VMHost -VM $_}},@{N=”Datastore”;E={Get-Datastore -VM $_}}

Actually vMotion

Move-VM vm-name -Destination (Get-VMHost esxi-hostname)

Actually Storage vMotion

Get-VM “vm-name” | Move-VM -datastore (Get-datastore datastore-name)

Search for things in Inventory. (Look for VMs that have an ‘v’ in them.

Get-VM | Where-Object {$_.name -match ‘v’}

List VMs with less than 1024MB of Memory

Get-VM | Where-Object {$_.MemoryMB -lt ’1024′}

See if any of our datastores have less than a certain amount of free space. First we’ll do 100,000MB. Then we’ll search for 3,000MB

Get-Datastore | Where-Object {$_.freespaceMB -lt 100000}

Get-Datastore | Where-Object {$_.freespaceMB -lt 3000}

Output a list

get-vm | select name, numcpu, memoryMB, @{n=”diskKB”; e={($_ | get-harddisk).capacityKB}} | ConvertTo-Html | Out-File c:\vms.html

Categories: Scripting Tags:

vNugglets: PowerCLI Hands On Lab Guide Released

August 6th, 2012 No comments

I wanted to spin up a quick post and link to some good content. My friends Matt Boren and Allen Crawford, authors of the world renowned vNugglets PowerCLI blog, wrote a great PowerCLI hands on lab guide for the Indianapolis VMUG “Demo Days” event that was held on July 26th. They’ve made the lab guide available for public consumption in the event that you want to go through it.

Snippet from their post:

This year’s lab starts out with some 101/102-level types of exercises and info, and then progresses into 200-level PowerCLI (and maybe a bit beyond). I cut off the lab guide at thirty (30) pages — there is so much to cover, and thirty pages got us through about 75% of the material we outlined to discuss. Now we have leftovers for next time.

Check it out on their blog at: http://vnugglets.com/2012/08/indy-vmug-demo-day-2012-powercli-lab.html

Go on, check it out!

Categories: Labs, Scripting, VMUG Tags:

VMware Publications Videos: Running vCLI 5 Commands

January 23rd, 2012 No comments

VMware Technical Publications has released another great video.  This one gives an overview of available authentication methods including session files, Active Directory, and configuration files. It also explains how to run commands against vCenterServer systems to target ESXi hosts in lockdown mode on vCLI in vSphere 5.0.

Check it out!

There is also another great vCLI video as well which gives an overview of vCLI commands in vSphere 5.0. Unlike the above video, this one discusses ESXCLI name spaces and commands and goes over commands for which no ESXCLI equivalent exists in vSphere 5.0.

Categories: Scripting, Videos, vSphere Tags:

PowerCLI VMUG Lab: Cincinnati Roadtrip!

October 28th, 2011 No comments

Back in July of this year, the Indy VMUG hosted a large regional event. After the numbers came in it was the largest VMUG event worldwide at somewhere around 900+ attendees. It’s came a long way. I remember helping plan the first “Demo Days” event and we were happy with 300 attendees and ran it out of a conference center on the IUPUI campus. Recently these events have had to be held in the Indiana Convention Center due to popularity. Nice!

At this years event, myself, Brian Wuchner and Jake Robinson, created a self paced PowerCLI lab. The lab was created to show some cool things that you can do with VMware PowerCLI and build up some additional interest. We built it on Bluelocks VMware vCloud environment. We received good feedback overall and put the content on the Indy VMUG site.

A few weeks ago the leaders at the Cincinnati VMUG, got in touch with us and asked if we could provide a lab at their full day event on 11/2. So we’ve updated the lab, and will take a road trip.

The lab is built similar to the layout below, however we built a VMware View front end for the Cincinnati event.

vCenter Server (localhost)
Two ESXi 4.1 hosts (named esxi01 and esxi02)
Four virual machines running on the above ESXi hosts (named alpha, bravo, charlie and delta)
Shared iSCSI appliance (Openfiler)

You can register for the Cincinnati event here: http://www.myvmug.org/e/in/eid=112

Beautiful artwork copyright Jake Robinson.

A special thanks goes to Bluelock (www.bluelock.com) for providing the virtual data center services and 10zig Technology (www.10zig.com) for providing the thin client devices.

Categories: Scripting, VMUG Tags: