Archive

Posts Tagged ‘Toolbox’

Copying VMware Network config / Port Groups

February 7, 2011 Leave a comment

How often do you need to duplicate the port group config from one ESX host to another – easy if you can use Host Profiles . . but maybe you are not licensed for it?

I found a great (FREE . . the best type) tool for this:

http://www.vladan.fr/itq-vlan-and-portgroup-manager-free-utility/

The author is Flores Eken from ITQ Consultancy in the Netherlands. He is a VMware SDK programmer. He wrote this application in C# based on the new ESX3.x /VC2.x SDK, but it works in ESX 4

you can download it at :

http://www.run-virtual.com/files/ITQ-VI-Setup.msi

Advertisements

Useful websites . . searching for Microsoft / Mac / Linux / BSD related results

February 1, 2011 Leave a comment

As a techie . . I heavily rely on google for answers to questions that relate to various IT systems (seeing as most people know more than me)

Well, the majority of my queries are related to Windows / Microsoft and supporting tools.

some of you may know this (and some of you may not), but Google has actually built a tool just for techies like us.

If you browse to http://www.google.com/microsoft.html you’ll be able to run a search that only queries websites that are specifically related to Microsoft support etc.

but this is not all . .there are a few others..

Apple Macintoshwww.google.com/mac Search for Mac & Apple things
BSDwww.google.com/bsd Search for the BSD operating systems
Linuxwww.google.com/linux Search for the Linux operating system
Microsoftwww.google.com/microsoft Search Microsoft-related pages
U.S. Government and state governmentswww.google.com/unclesam Search .gov, .mil and state sites
Universitieswww.google.com/options/universities.html Narrow your search to a specific institution’s website

Definitely worth a look (methinks)

Categories: Toolbox Tags: , ,

Script of the day – writing to a cell in Excel

January 31, 2011 Leave a comment

Ever needed to inject info to a cell in an Excel spreadsheet – repeatedly . . . you can do so from Powershell . . like so:

Function write-excel ($ExcelFile, $WorkSheet, $Column, $Row, $Value) 
{
<#
	.SYNOPSIS
	 Write value(s) to Excel cells 
	.DESCRIPTION
	 No return - Updates an Excel Cell
	.PARAMETER  
		e.g. Specify the requested parameter, if not specified this will be prompted
	.EXAMPLE
		PS C:\> write-excel $ExcelFile $WorkSheet $Column $Row $Value
#>
	$File = (ls $ExcelFile).FullName
	# Open Excel
	$Excel = New-Object -Com Excel.Application
	
	# Prevent Overwrite and Macro Prompt
	$Excel.displayalerts=$False 

	# Open Template File 

	$WorkBook = $Excel.Workbooks.Open($File)
	$WorkSheet = $WorkBook.Worksheets.Item("$WorkSheet")
	$Worksheet.Cells.Item($Row,$Column) = $Value

	# Setting All Variables to Null

	$WorkBook.SaveAs($ExcelFile,1)
	$Excel.Quit()
 	$WorkBook = $Null
	$WorkSheet = $Null
	$Excel = $Null

	# Releasing Object Wrapper

	[GC]::Collect()
}

Importing a VM from VM Workstation to ESX / ESXi

January 28, 2011 Leave a comment

Importing and exporting virtual machine from a VMWare ESX Server host requires converting that virtual machine’s .vmdk file(s) from one format to another.
Although the underlying technologies work the same, the formatting of the VMDKs differ.

You have 2 options:
1) If you have a running copy of workstation, simply use VMware Converter as you would for any normal conversion, treating the VM as you normally would a physical host in a P2V
2) If you have no working Workstation, you can clone / convert the vmdk at the command line – as I have a fully ESXi lab to play in, I don’t have Workstation running on any machines in my office – as such, when IBM recently supplied a VM for a demo . . that had been created on VM workstation, I had to import it. I used the following process.

Firstly, get hold of an SSH tool ( I use putty)

Next, open a connection to any host that has the storage containing the vmdk presented

In ESX / ESXi, this will be in /vmfs/volumes/<datastorename>

Note: the destination path /dest/folder/vmserver1.vmdk should not contain any existing files with the name ‘vmserver1.vmdk’. If it does the file will be overwritten.

Importing Virtual Disks from GSX Server and Workstation to ESX Server

Before an ESX Server can run a virtual machine created on a different version of VMWare, the virtual disks must first be converted to a format that can be read by the VMFS file system. This is done by running the following vmkfstools command:

vmkfstools -i <folder>/<filename>.vmdk <vmhba number>:<filename>.dsk

<folder> is the name of the folder from which you are importing from

<filename> is the name of the virtual machine file(s) to be imported

<vmhba number> is the name of the VMFS partition you are importing to

An example of a complete command would be:

vmkfstools -i /vmfs/volumes/CLRLAB001T1/vmserver1.vmdk /vmfs/volumes/CLRLAB001T1/vmserver1_new.vmdk

Additional information regarding the vmkfstools command can be found in the ESX Server documentation.

Powershell – Script of the Day – Menu-Plus

January 27, 2011 Leave a comment

Yesterday, we created a simple Powershell menu

https://geekseat.wordpress.com/2011/01/26/script-of-the-day-powershell-menu-select-list/

Today’s script is a feeder for the menu, that allows you use any filed of an object as your menu source and return a different field of it as your return value.

For Example:
the following query will give you a list of the filenames in the current directory, once you select an item, it will return that ‘LastWriteTime’ of that file. – Simple

PS:8 &gt;menu-plus -object (gci) -displayfield "name" -menuTitle Please select a file -returnfield "LastWriteTime"
Function menu-plus ($object, $displayfield, $menuTitle, $returnfield)

{
&lt;#
.SYNOPSIS
Feeder object to Menu Function to Enable return of different field in Object

.DESCRIPTION
Requires:Menu Function
Creates a menu that allows return of a different object field.

.PARAMETER
$object - the array that we're sselecting from
$Displayfield : Name of the field that will be displayed for selection
$MenuTitle : The prompt to included at top of menu
$Returnfield : Field to be returned - defauilts to all fields

.EXAMPLE

PS: &gt;$a = gci
PS: &gt;$b=menu-plus -object $a -displayfield "name" -menuTitle Please select a file -returnfield "LastWriteTime"
¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
¦ Please select a file ¦
¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
CDB

Compare
Decom
edit-table
temp.csv
PS:87 &gt;$b.LastWriteTime
25 March 2010 15:20:53
#&gt;
$menulist = @()
ForEach ($item in $object){$menulist += $item.$displayfield}
$returnval = menu $menulist $menuTitle $returnfield
$output = $object | where {$_.$displayfield -eq $returnval} | Select $returnfield
return $output
}

Script of the Day – Powershell Menu Select list

January 26, 2011 2 comments

Sometimes you’d like to prompt a user to select an option from a list in Powershell . .

try this:


Function menu
{
<#
	.SYNOPSIS
	 Generate a small "DOS-like" menu.
	.DESCRIPTION
	  Allows you to pick  a menuitem using up and down arrows, select by pressing ENTER
  	.PARAMETER  
		e.g. Specify the requested parameter, if not specified this will be prompted
	.EXAMPLE
		C:\> $Options = "Option1", "Option2", "Option3", "Option4", "Option5"
		C:\> $selection = Menu $Options "Please select an Option?"
		
		****************************
		* Please select an Option? *
		****************************

		Option1
		Option2
		Option3
		Option4
		Option5
		
		write-host $selection
		Option1
		
#>
    param ([array]$menuItems, $menuTitle = "MENU", [switch]$quit)
    $vkeycode = 0
    $pos = 0
	If ($quit){$menuItems += "Quit"}
    DrawMenu $menuItems $pos $menuTitle
    While ($vkeycode -ne 13) {
        $press = $host.ui.rawui.readkey("NoEcho,IncludeKeyDown")
        $vkeycode = $press.virtualkeycode
        Write-host "$($press.character)" -NoNewLine
        If ($vkeycode -eq 38) {$pos--}
        If ($vkeycode -eq 40) {$pos++}
        if ($pos -lt 0) {$pos = 0}
        if ($pos -ge $menuItems.length) {$pos = $menuItems.length -1}
        DrawMenu $menuItems $pos $menuTitl
    }
	If ($($menuItems[$pos]) -eq 'Quit'){return}
	Else
	{Write-Output $($menuItems[$pos])}
}



function DrawMenu {
    ## supportfunction to the Menu function above
    param ($menuItems, $menuPosition, $menutitle)
    $fcolor = $host.UI.RawUI.ForegroundColor
    $bcolor = $host.UI.RawUI.BackgroundColor
    $l = $menuItems.length + 1
    cls
    $menuwidth = $menutitle.length + 4
    Write-Host "`t" -NoNewLine
    Write-Host ("#" * $menuwidth) -fore $fcolor -back $bcolor
    Write-Host "`t" -NoNewLine
    Write-Host "# $menutitle #" -fore $fcolor -back $bcolor
    Write-Host "`t" -NoNewLine
    Write-Host ("#" * $menuwidth) -fore $fcolor -back $bcolor
    Write-Host ""
    Write-debug "L: $l MenuItems: $menuItems MenuPosition: $menuposition"
    for ($i = 0; $i -le $l;$i++) {
        Write-Host "`t" -NoNewLine
        if ($i -eq $menuPosition) {
            Write-Host "$($menuItems[$i])" -fore $bcolor -back $fcolor
        } else {
            Write-Host "$($menuItems[$i])" -fore $fcolor -back $bcolor
        }
    }
}

Extending a Windows C:\ Dell EXTPart

January 26, 2011 Leave a comment

I get many requests to extend the C:\ (or any other drive)
Most times these are for VMs – so it is pretty easy right? Extend the amount of disk allocated to the virtual machine, then extend in Computer Management – or using diskpart?

Well this does not always work – see, Windows does not really like you messing with system drive.

Well, Dell have come up with a brilliant tool called EXTPart
http://support.dell.com/support/downloads/download.aspx?c=us&cs=19&l=en&s=dhs&releaseid=R64398&formatcnt=2&fileid=83929

All you need to do now is provision the extra space to the VM, then run the tool at the command line and follow the wizard:

C:\>extpart.exe
ExtPart - Utility to extend basic disks (Build 1.0.4)
(c) Dell Computer Corporation 2003

Volume to extend (drive letter or mount point): c:
Current volume size : 66285 MB (69504860160 bytes)
Current partition size : 76285 MB (79990815744 bytes)
Size to expand the volume (MB): 76285

that’s it – job done . . zero downtime (watch out of course . . this works differently if you have a clustered disk to extend – see:  https://geekseat.wordpress.com/2011/01/25/replacing-clustered-storage-for-a-sql-cluster-emc-ce-ms-clustering/ )