Remove files older than x days with PoSH


image

One of the Symantec Live Update Servers started to complain about low disk space. So I started Treesize Pro to see what files or folders where eating my disk space.  After a couple of seconds Treesize Pro showed me that the liveupdate files, in the c:\LiveUpdate folder where the problem.

I created the following Powershell Script (after reading the source) and scheduled this script to run once a week.

Warning: This script will remove everything that matches the remove-item cmdlet!



$Now = Get-Date
$Days = "3"
$TargetFolder = "C:\LiveUpdate"
$LastWrite = $Now.AddDays(-$days)
$Files = get-childitem $TargetFolder -include *.zip, *.x86 -recurse `
    | Where {$_.LastWriteTime -le "$LastWrite"} 

foreach ($File in $Files)
{write-host "Deleting File $File" -foregroundcolor "Red"; `
    Remove-Item $File | out-null}

Just change the $Days, $TargetFolder variables and the file extensions (*.zip, *.x86) for you environment.
Source of this script: powershell-script-to-delete-files-older-than-certain-days.aspx

Convert a *.VHD with VMware Converter 4


image

I created a short movie about the process of converting a Microsoft VHD image into a VMware Virtual Machine VMware Converter 4 Standalone. You can download the VMware Converter 4 standalone version here: http://www.vmware.com/download/converter/

screencast


Due to problems with embedded movie players and a WordPress.com hosted blog, I can’t embedded the movie here. So click on the above picture or op the following url: VMware_Converter_4_Standalone_Convert_VHD

VI Toolkit 1.5 + VUM = Error


image

I was experimenting with the VUM Powershell library. I ran the Get-Baseline cmdlet and then the following error occurred:

image

After some digging around at goolge and vmware.com. I found that  the VUM library doesn’t work with the new version of the VI Toolkit. VMware is aware of the problem according to the post from Carter on VMTN and the Release notes:

Carter Shanklin posted this information on VMTN:

Hi everyone,

There is an incompatibility between VI Toolkit 1.5 and the VUM cmdlets. For now if you need to use the VUM cmdlets you will need to do so on a system that has VITK 1.0 installed.
This incompatibility will be resolved by a minor update to VI Toolkit that will be shipped when the next version of VUM ships. The next version of VUM will have cmdlets that support that version as well as the current version.

We’ve updated the release notes to note the incompatibility. Sorry for the inconvenience.

From the release notes:

VI Toolkit (for Windows) 1.5 is not compatible with VMware Update Manager – PowerShell Library 1.0.

windowstoolkit15-200901-releasenotes.html

To fix this “problem” I removed the VI Toolkit v 1.5 and installed the VI Toolkit v 1 again. After the rollback, the VUM library is working again :-).

I hope that VMware will fix this soon.

VMware: VMware vCenter Mobile Access


image

John Troyer just dropped the news on Twitter:

image

This is what vCenter Mobile Access can do:

Introducing VMware vCenter Mobile Access (vCMA).  vCMA allows you to monitor and manage VMware Infrastructure from your mobile phone with an interface that is optimized for such devices. Specifically, it allows you to:

  • Search for virtual machines in your data center
  • Migrate virtual machines from one host to another using vMotion
  • Execute recovery plans using VMware Site Recovery Manager
  • Access Scheduled Tasks, Alarms and Events
  • And much more…

More info and a short demo can be found over here:  http://blogs.vmware.com/vmtn/2009/03/introducing-vmware-vcenter-mobile-access.html

Debian: Add a new hard disk via cli


image
These are the steps to add a new hard drive using the cli:

  1. run fdisk –l.  in this how toI will add device: /dev/sdb
  2. use cfdisk /dev/sdb  to create a new partition:
         image 3. Then again,  run the fdisk –l  commando to see the new patition. It has been changed to /dev/sdb1.
    4. format the drive with EXT3:  mkfs.ext3 /dev/sdb1
         image

      5. next you create a mount folder: mkdir –p /media/newdisk
     
    6. mount the drive: mount /dev/sdb1 /media/newdisk/ 
     
    7. the final step, add the new mount point to the /etc/fstab. If you don’t do this step, the new disk will not mounted at boottime. Open the /etc/fstab in your favorite editor. Add the following line: /dev/sdb1 /media/newdisk ext3 defaults 0 2
      8. Reboot the debian machine to see if everything works as expected.
      as you can see, everything went smooth.
     image  

Source: http://rblondon.blogspot.com/2007/09/installing-new-hard-disk-on-debian.html

Installing Veeam Backup 3.01


image

After reading the post about the release of Veeam Backup 3.01 over at http://virtualfuture.info/. I downloaded the software and upgraded to version 3.01. In this post you’ll find the information you need about the upgrade process.

image

1. Uninstall Veeam Backup 3.0. Your Product configuration will be preserved in the Veeam Backup configuration database.
2. Download Veeam Backup 3.0.1 from http://www.veeam.com/download_all.asp
3. Extract the downloaded archive and run the Veeam_Backup_Setup.exe setup file.
4. Accept the terms of Veeam Backup and FastSCP License Agreement to install the product.
5. Provide setup program with your license file.
6. Specify the installation folder.
7. Specify the Microsoft SQL server database and instance to use for storing Veeam Backup configuration. You should select the same database and instance you have used for Veeam Backup 3.0.

image

8. Confirm that you want to use existing Veeam Backup configuration database when prompted.

image

9. Specify the administrative credentials to run the Veeam Backup service. The account must have Local Administrator privileges on the computer where you are installing Veeam Backup.
10. Click Install to start the installation.
11. Launch the Veeam Backup product by clicking the Veeam Backup and FastSCP product icon on your desktop.

Source:  veeam_backup_3.0.1_release_notes.pdf

VKernel: Snapshot My VM’s


image

Gerben Kloosterman just posted about the release of Snapshot My VM’s:

After the two products SearchMyVM and CompareMyVM Vkernel released another free tool called SnapshotMyVM. SnapshotMyVM is a tool to document your VM’s.

Here’s a sampling of the information you can get with SnapshotMyVM:

  • VM name
  • Guest operating system
  • Host hardware type, manufacturer, and version
  • VM resource (CPU, memory, storage, network) configuration
  • VM resource utilization statistics (saves a week of historical data)

This is how you get the app running:

  1. Download the SnapshotMyVM.jar file here: http://www.vkernel.com
  2. Install Java JRE 1.6.x
  3. Open a command prompt and enter the following command:

java –jar <path_to_download>\SnapshotMyVM.jar

image

The application will start:

image

You can also create a shortcut:

image

 

Source: http://blog.virtualarchitect.nl/2009/03/release-vkernel-snapshotmyvm/

VMware: Start the VI Toolkit on Win 7


After installing Windows 7 build 7057 x64 the VI Toolkit starts with the following error /warning. If  you run the Set-ExecutionPolicy unrestricted  command as a normal user, the command will not run successfully.

image

The solution is simple: Open the VI Toolkit with the Run as administrator permissions option.

image

When the VI Toolkit window pop’s up. Run the Set-ExecutionPolicy unrestricted command, and the VI Toolkit starts without the error.

image

VMware: Failed to get disk partition information


After creating a new IETD configuration at home, i wanted to add the new iSCSI LUN to my ESXi server. Everything went fine, the LUN was presented and the Add storage wizard has found the new LUN. But when i wanted to complete the wizard, the following error came up: 

image

In KB2240, you’ll find the following solution:

The easiest workaround is to use another disk for a datastore. If this is not possible, create the VMFS datastore manually. To do this:

  1. Use fdisk on the /dev/sd[a-z]* device. Create a partition with type 0xfb.
  2. Format the VMFS datastore using
    vmkfstools -C vmfs3 vmhbaI:T:L:P
    In this example, I corresponds to the initiator of the VMware host bus adapter, T corresponds to the target number of the disk, L is the LUN number, and P is the partition number of the newly created partition.

If you don’t know how to use fdisk, you can use this guide:

1. Log on to the console or use putty to connect to the ESX host remotely. If you have not created a user for yourself you will not be able to log in through putty.

2. SU to root. This must be done using the su – root command. If you do not use the – then you will not get root’s path and thus get error messages that say that commands cannot be found.

3. Run fdisk -l. This will give you a list of all of your current partitions. This is important because they are numbered. If you are using SCSI you should see that all partitions start with /dev/sda# where # is a number from 1 to what ever. Remember this list of number as you are going to be adding at least one more and will have to refer to the new partition by it’s number.

4. Run fdisk /dev/sda. This will allow you to create a partition on the the first drive. If you have more than one SCSI drive (usually the case with more than one RAID container) then you will have to type the letter value for the device you wish to create the partition on (sdb, sdc, and so on).

5. You are now in the fdisk program. If you get confused type "m" for menu. This will list all of your options. There are a lot of them. You will be ignoring most of them.

6. Type "n". This will create a new partition. It will ask you for the starting cylinder. Unless you have a very good reason hit "enter" for default. The program will now offer you a second option that says ending cylinder. If you press enter you will select the rest of the space. In most cases this is what you want.

7. Once you have selected start and end cylinder you should get a success message. Now you must set the partition type or it’s ID. This is option "t" on the menu.

8. Type "t". It will ask you for partition number. This is where that first fdisk is useful. You need to know what the new partition number is. It will be one more than the last number on fdisk. Type this number in.

9. You will now be prompted for the hex code for the partition type. You can also type "L" for a list of codes. The code you want is "fb". So type "fb" in the space. This will return that the partition has been changed to fb (unknown). That is what you want.

10. Now that you have configured everything you want to save it. To do so choose the "w" option to write the table to disk and exit.

11. Because the drive is being used by the console OS you will probably get an error that says "WARNING: Re-reading the partition table failed with error 16: device or resource busy." This is normal. You will need to reboot.

12. To reboot the server type "reboot" at the prompt.

13. Once you have rebooted you can now format the partition VMFS. DO NOT do this from the GUI. You must once again log into the console or remote in through putty.

14. Once you have su’d to root you must type in "vmkfstool -C vmfs3 /vmfs/device/disks/vmhba0:0:0:#" Were # is the number of the new partition. You shoulder now get a "successfully created new volume" message. If you get an error you probably chose the wrong partition. Do an fdisk – l and choose the number with the "unknown" partition type. Note: IF you have more than one SCSI disk or more than one container the first 0 may need to be a 1 as well.

15. Go to the GUI and in configuration/storage select refresh. You should now see your new VMFS volume.

Source: http://communities.vmware.com/docs/DOC-1382