PowerCLI: Search and Destroy Old VMware SnapShots

We all know it's bad to leave snapshots lying around in VMware. Snapshots grow over time and can cause disk space and performance issues. Sometimes it's easy to forget that you created them. So you should periodically check to see what snapshots are out there. PowerCLI (PowerShell with the VMware snapin) provides a great way to do this.

The following script looks for snapshots on each VM in a vCenter environment. If the snapshot is 3 day old (or older), it will delete it. Well, I've got the -WhatIf switch on the remove command, so it won't actually delete anything unless you remove -WhatIf. You can also remove the -Confirm switch so it won't prompt you as it goes.

I put this together from bits and pieces I found on the web, so thanks for the help y'all.
$vcenter = "my-vcenter"

$maxAge = (Get-Date).AddDays(-3)

if (get-pssnapin vmware*) {
 # we're good
} else {
 Add-pssnapin VMWare.VimAutomation.Core

Connect-VIServer $vcenter


Get-VM | Foreach-Object {
 $vmname = $_.Name
 Get-Snapshot -VM $_ | Foreach-Object {
  $snapshot = $_.Id
  $size = "{0:N3}" -f $_.SizeGB
  if($_.Created -lt $maxAge) {
   if($found -eq 0){
    $found = 1
    "`nVM Name     `tSnapShot ID              `tSize (GB)`tDate Created"
   "$vmname`t$snapshot`t$size`t" + $_.Created
   Remove-Snapshot $_ -Confirm -WhatIf

if($found -eq 0){
 "`nNo old snapshots found!"
Disconnect-VIServer -Confirm:$False

Ubuntu Quick Start

Want to run Ubuntu quick and easy, without an extra PC? You can run it in a virtual machine on your Windows PC. You can get really good free virtualization software that not only lets you run Ubuntu on Windows, but it also simplifies the Ubuntu installation. The software? VMware Player. So first things first, let's download a copy of VMware Player. You can find it at:

After downloading it, launch the installer. Follow the prompts, and complete the install.

Next, let's get a copy of Ubuntu. Although there are newer versions, I'd recommend that you start with the most recent "long-term support" (LTS) version, which as of this writing is version 12.04 LTS. Actually, next month, 14.04 LTS should be coming out, but we'll see if it's good and stable like 12.04. I expect it will be.

You can get Ubuntu Desktop, which includes a GUI, or you can get Ubuntu Server, which is text only. If you're just learning Linux, I'd suggest that you install the desktop version, as the GUI can be helpful for newbies. You can do all the server stuff with a desktop anyway. You can download Ubuntu Desktop at http://www.ubuntu.com/download/desktop. Select version 12.04 LTS. Choose the 64-bit version if you are running a 64-bit version of Windows, otherwise choose the 32-bit version.

Once the download is finished, launch VMware Player.

Now, click on "Create a New Virtual Machine. In the next screen, select "Installer Disc Image File (ISO)", and browse to the Ubuntu ISO image you downloaded. Player should detect Ubuntu on the ISO and suggest the "Easy Install" mode as shown here.

Sounds great, let's do that. Click Next, and Player will prompt you for a username and password to setup in Ubuntu.

On the next screen, you will specify a name for the VM, and the path to store the VM's files. The screen after that shows the virtual disk configuration. The defaults are advisable, and don't worry, Player doesn't use all of the space all at once. Space is consumed as data is written. So even though the default is a 20 GB disk for Ubuntu, it will likely only take up around 3 GB once Ubuntu is installed.

Next, at the summary page, click the "Customize Hardware" button. Have a look at the memory configuration. 1 GB of RAM should be enough. Increasing the amount of RAM given to the VM doesn't hurt, unless your PC doesn't have it to give, in which case your PC will start to swap like mad while the VM is running, and performance will be horrible. If you're tight on RAM, you can reduce the amount to say, 768 MB. That's still enough to run Ubuntu. Even 512 would do in a pinch.

Next, click on the Processors item. I would recommend giving the VM four CPUs (if you have that many). Two might be enough if you have a fast CPU, but I find that on my I-5 processor, 2 is a little under powered. Note that I have an I-5 Gen 1, which really only has two cores in it, but hyperthreading is enabled, so I see 4.  

Click Close when you're done, then click Finish to build the VM. Player will begin the Ubuntu installation. Assuming this is your first Linux install, you will immediately be prompted to download VMWare Tools for Linux.

Go ahead and Download it while the install is running. VMware Tools will be installed in Ubuntu and help things run a bit smoother, like resizing the desktop when you resize the VM's window. Meanwhile, you will see the Ubuntu installer doing its thing.

After the installer completes, the VM will reboot and VMware Tools will be installed in the VM. When that's done, Ubuntu will finish booting and bring you to the login screen.

Enter the password that you specified earlier, and press enter. Congratulations, you've logged into your brand new virtual Ubuntu desktop. What you're looking at is Ubuntu's Unity desktop. There's an icon bar on the left side of the screen. That top icon is like the Windows start button. If you click it, you can access all of the programs that have icons on the machine. The text box allows you to type the name of a program and it will find icons that match the letters as you type. Let's type term to find the terminal application.

Click on the Terminal icon and the terminal will open. The first thing we want to do is get all the patches up to date, so we can be as secure and bug free as possible. In the terminal, type the following commands:

sudo apt-get update

(you will be prompted for your password). Then type:

sudo apt-get dist-upgrade

When prompted, answer Y to proceed with the updates. It should take a few minutes. After the updates are complete it's advisable to reboot and login again. Type:

sudo reboot

After the reboot and you've logged in again, you can go about the business of falling in love with Ubuntu. A few more tips. You will find an icon that looks like a shopping bag. That's the Software Center. Launch it and have a look around. There's a huge amount of free software available to install. Ubuntu comes with the Firefox web browser by default, but if you're a Chrome fan, you can find it in Software Center (it's called chromium). Or you can install it via the terminal by typing:

sudo apt-get install chromium-browser

Last tip. I'm not a big fan of the Unity desktop. I much prefer the Gnome desktop. To install it, type:

sudo apt-get install gnome-shell

After it's installed, logout (via that gear icon in the upper right corner of the screen). At the login screen, click the little Ubuntu icon next to your name, and select the gnome icon instead (the foot). Enter your password and you will be in the Gnome interface. To switch back to Unity, logout, select the Ubuntu icon, you get the idea.

Hope you enjoy it!

Tools: Active Directory Automation and Rules Enforcement

Many Active Directory administrators are often faced with daunting tasks on a daily basis, like generating reports, importing and exporting users from one platform to another, enforcing security standards, etc. With the adoption of cloud computing, Identity and access management tasks extend beyond Active Directory to a myriad of other platforms, such as Office 365, Microsoft Exchange, and more. Provisioning and managing user accounts across many platforms, using the native tools of each platform, quickly becomes an enormous task if you've got more than a handful of users.

Most administrators are forced to plod along, performing manual tasks using the native tools, using their mouse to navigate through screens in the Active Directory management tools, or web-based consoles offered by the cloud-based platforms. Some platforms offer command-line tools, scripting toolkits, or published web service API's, and some advanced administrators have tackled the steep learning curve to incorporate these into their processes.

As more and more services are migrated to the cloud, more user accounts, more web consoles, more API's, and more manual processes will only make administrator productivity get worse and worse. What we need is a way to abstract the management of each platform into a framework that provides a standardized administration process across these platforms.

Cayo Admin AssistantTM provides a graphical interface to build and schedule automated processes across multiple platforms. Common tasks are created by grouping together building blocks that Cayo calls "commands". For example, there's a command for querying Active Directory for user accounts. Combine that with commands for filtering, sorting and exporting the results, and you've got your reports. Another powerful example is to query Active Directory for new users, sort and filter the results, and provision those new users in Office 365 or any other platform for which you have the extension installed. Admin Assistant enables automation and scheduling of repetitive tasks, business rules enforcement, bulk administration and reporting across multiple platforms using a single interface.

Cayo Admin Assistant
Admin Assistant is extensible. Extensions provide the needed commands for a given platform. Out of the box, the Active Directory extension is available, as well as a Utility extension which provides common filtering, sorting, import/export and other miscellaneous commands. Also available are extensions for Office 365 and Microsoft Exchange (this extension is currently in Beta as of this writing), with more on the way. These extensions enable Admin Assistant to provide a single interface through which common administrative tasks can be performed across your multi-platform hybrid cloud environment.

If Admin Assistant doesn't provide the command, let Cayo know! They're constantly working on new commands that will be released as product updates, as well as new extensions, such as the Microsoft Azure extension. As your company deploys services onto new platforms, and as Cayo delivers the extensions for that platform, your administrators will be able to hit the ground running, performing administrative tasks on the new platform using one common interface, without reinventing the wheel each time.

Admin Assistant can be purchased as part of the Cayo AdministratorTM Suite, or purchased separately. Download your free trial at www.cayosoft.com.

Related Posts Plugin for WordPress, Blogger...