Use the blue Nav bar above to access the main index pages!

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

$found=0

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:
https://my.vmware.com/web/vmware/free.../vmware_player/6_0

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: User Provisioning Made Simple

Creating new users is becoming more complex as we add more services to our IT environments.  Over the years, many enterprises have adopted Active Directory, Exchange and Lync, and more recently we've been adding cloud services like Office 365 and SalesForce.com.  The result is a user provisioning process that is more and more complex, error prone, and manually intensive.

What we need is a tool that allows us to enter the user's information once, and then, using pre-defined settings and formats, provision the user across multiple platforms, all in one consistent operation.  Later, when a user leaves the company, we need to be able to quickly and simply de-provision the user's accounts as well.

Any Active Directory administrator knows that creating a user account can be a chore, especially if you intend to be thorough, putting the user in the correct OU, populating all the miscellaneous fields like street address and organizational fields.  To do this by hand is a lot of work, and there's plenty of opportunity to get it wrong.  On top of all that, in many organizations, you have to switch tools, perhaps many times, to enable the user for Exchange, Lync, and external cloud services.

If you're doing administration for a global enterprise, you might have many sites with different standards: different street addresses, different Exchange servers, different naming conventions, the list goes on.  What we need is a tool that can define standard settings per site, per department, per user role, what ever we want to create, save, and reuse, to make user provisioning easier.

Zohno has created Z-HireTM and Z-TermTM for IT account lifecycle automation.  These tools let the administrator create multiple templates for user provisioning (Z-Hire) and de-provisioning (Z-Term).  Each template can contain default settings and user name formats for creating user accounts in Active Directory, Exchange, Lync, Office 365 and SalesForce.com.  Multiple templates can be used for different sites, departments, whatever you need.  The template can specify user settings in Active Directory and Office 365, Exchange mailbox settings, Lync policy settings, and much more.

Z-Hire
There's also a section for specifying a custom script to run, passing user information as script arguments.  This allows additional custom provisioning tasks to be performed.

User naming conventions can be specified in the template by using variable names like %firstname%, %lastname%, %firstinitial%, etc.  Once the defaults have been saved to a template, the administrator can simply select the correct template, enter the user's name, and the tool will calculate the resulting information, based on the template, to use when provisioning the user across all of the selected services.

When a user leaves the company, it's time to de-provision the user's accounts.  Enter Z-Term.  Again, Z-Term allows the administrator to create templates, which determine what to do with the user's account.  You may want to disable the user's account, move it into a specific OU for terminated accounts, remove the user's group memberships, reset the password, etc.  Z-Term let's you specify what steps to take, and save them to a template.  You may want different templates for different sites, departments, etc.

Z-Term
Once the templates are setup, the administrator simply selects the correct template, enters the user to de-provision, and the tool performs all the necessary steps across all of the selected services.  The administrator can also define file operations to occur on termination, such as copying the user's home directory and roaming profile to a backup location, and again, run a custom script to do special things unique to your environment.

Z-Term and Z-Hire are a huge help for the busy administrator, reducing the time and effort required to manage user accounts, while improving accuracy and reducing errors.  It's "user provisioning made simple".  Z-Term and Z-Hire are licensed per the size of your organization.  You can download a 90-day trial, and buy a license at www.zohno.com.


Related Posts Plugin for WordPress, Blogger...