Tuesday, January 31, 2012

Unable to install VMware Tools

IBM HS22 Blade with IBM ESXi 4.1update2  USB Key
VMware tools installation fails with the error below...

Unable to install VMware Tools. An error occurred while trying to access image file "/usr/lib/vmware/isoimages/windows.iso" needed to install VMware Tools: 2 (No such file or directory). If your product shipped with the VMware Tools package, reinstall VMware ESX, then try again to install the VMware Tools package in the virtual machine.
 The required VMware Tools ISO image does not exist or is inaccessible.

Troubleshooting
SSH to the Vmware host reveals that the /usr/lib/vmware is not accessible




ls -l reveals that the isoimages folder is a symbolic link to /productLocker/vmtools/


cd /productLocker is inaccessible




/vmfs/volumes is missing Hypervisor3




The ESXi partition table can be checked using the command fdisk -l













There is a Warning for partition table 8
Warning: ignoring extra data in partition table 8

And the file system for mpx.vmhba32:C0:T0:L0p8 is Unknowm
/dev/disks/mpx.vmhba32:C0:T0:L0p8   ?    740786   1480957 757935405   5a  Unknown

mpx.vmhba32:C0:T0:L0p8 should be the scratch disk location.

The fix

It is recommended that the persistent scratch location be set for ESXi

Configuring persistent scratch location using the vSphere Client

You can configure persistent scratch space for ESXi using the vSphere Client:
  1. Connect to vCenter Server or the ESXi host using the vSphere Client.
  2. Select the ESXi host in the inventory.
  3. Click the Configuration tab.
  4. Click Storage.
  5. Right-click a datastore and select Browse.
  6. Create a uniquely-named directory for this ESX host (eg, .locker-ESXHostname)
  7. Close the Datastore Browser.
  8. Click Advanced Settings under Software. 
  9. Select the ScratchConfig section.
  10. Change the ScratchConfig.ConfiguredScratchLocation configuration option, specifying the full path to the directory. For example:

    /vmfs/volumes/DatastoreName/.locker-ESXHostname
  11. Click OK.
  12. Put the ESXi host in maintenance mode and reboot for the configuration change to take effect.
Recreating scratch files including Vmware tools iso's.

Once the scratch  location has been set you can run the current ESXi 4.1 update 2 patch this will recreate the Vmware tools installation iso in the scratch file location.

Once the patch has applied reboot the host.

You can check that the vmtools iso's have been created by browsing the persistent scratch datastore.















You will then be able to deploy Vmware tools

Wednesday, July 13, 2011

AD Migration moving data to a new server

During a Domain Migration you may want to move file data from an old server in the old domain to a new server in the new domain.

You can use robocopy http://sjmeyers.blogspot.com/2011/05/migrating-data-between-servers.html to migrate the data but you will still be left with old permissions.


You can run the Active Directory Migration Tool ADMT to do a security translation on the new server to change security on files and folders to the new domain.

Open ADMT Security Translation Wizard

Select Previously migrated objects


Select the old domain as the source and the new domain as the target


Select the computer(s)

Select Files and folders

Select Replace

Select Finish


 Run  pre-check and agent operation
Once Agent has run you can verify the logs


Then check file permissions have changed to the new Domain

Please note permissions will only be translated the the new Domain if the Group was previously migrated and has sid history.
In the example above the Domain users Group hasn't been migrated yet.

The Security Translation wizard can be run more than once on the same server. 

Wednesday, May 18, 2011

Adding a Printer with Group Policy Preferences

You can add printers using Group Policy Preferences which is new in Server 2008 provided you have the Group Policy Preference Client Side Extensions installed on the client machines.

Group Policy Preferences are added though the normal Group policy Console.



You can Create, Replace, Update, Delete as required. You can also set as the default printer.

 

If more granular control is required click the Common Tab.
You can apply the setting only once and use the Targeting Editor to get really specific

 

Tuesday, May 17, 2011

Migrating Data between Servers

Robocopy is a good option when migrating data to another server.

It has a number of switches that can preserve attributes, timestamps, security, owner info, auditing info, etc...
Also it can include, exclude, add attributes, rerun and much more.

For a full list of operations type robocopy /? at the command prompt.

I recently migrated data to a new server using the following...
robocopy source destination /E /DCOPY:T /PURGE /COPYALL /TEE /LOG+:c:\robocopylog.txt

/E :: copy subdirectories, including Empty ones.
/DCOPY:T :: COPY Directory Timestamps.
/PURGE :: delete dest files/dirs that no longer exist in source.
/COPYALL :: COPY ALL file info (Data, Attributes, Timestamp, Security, Owner, Auditing).
/TEE :: output to console window, as well as the log file.
/LOG+:file :: output status to LOG file (append to existing log).

The method I used was to copy the data over and checked that everything was OK.
I then disconnected the users on the source, reran the command, and pointed the users to the new location.

Using this method the second run only copied over the changes (and removed anything that was no longer there) so took alot less time than the first run.

Sunday, May 15, 2011

How to reclaim Disk Space using Vmware Thin provisioning

If your drive is thick provisioned
You will need to use either Vmware Tools, Shrink or sdelete
Vmware tools Shrink
 
Sdelete
 
Then migrate to a new datastore.
Note: there is currently an issue where you will need to migrate to a new datastore with different block size.

If your drive is already thin provisioned
Vmware Tools Shrink isn’t available.
You will need to use sdelete to zero out disk then migrate to new datastore.
Warning: using sdelete will expand the thin provisioned disk to it’s full provisioned size so make sure you have enough space on the datastore free.
Note: there is currently an issue where you will need to migrate to a new datastore with different block size.

Monday, April 4, 2011

VB Script to list the current logged in user

The Scipt below reads computers from c:\temp\computers.txt and lists the user who is currently logged in.

'List user currently logged on to a desktop

WScript.Echo "List Currently logged in user for Computers in c:\temp\computers.txt"
On Error Resume Next
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("c:\temp\computers.txt", ForReading)
strText = objTextFile.ReadAll
objTextFile.Close
arrComputers = Split(strText, VbCrLf)

For Each strComputer In arrComputers  
 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
 Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
 For Each objItem in colItems
 WScript.Echo "UserName: " & objItem.UserName & " is logged in at computer " & strComputer
 Next
 Set objItem = Nothing: Set colItems = Nothing: Set objWMIService = Nothing
Next
WScript.Echo "Script Finished"

VB Script to Execute Wake on LAN on a different subnet

Wake on Lan packets won't travel over different subnets.

Below is a script which remotely executes the command on a host computer on the same subnet to send the WOL packet.

You will need
  • WOL capable computer you wish to wake.
  • A host machine on the same subnet as the comptuer you wish to wake.
  • WOL software http://sourceforge.net/projects/wake-on-lan/ extract the software to C:\temp\wol
  • MAC address of computer you wish to wake (you can get from DHCP) .
The script copies the WOL files from C:\temp\WOL to the host then remotely executes the command.

'Copy Wake on LAN files to remote computer then execute WOL
'Allows you to select remote computer on a different subnet as a host and wake another computerOption Explicit
Dim strHostComputer, strMAC, strIPComputer, objFSO
Dim objWMIService, objProcess, errReturn
Dim strComputerOn, Count, strCommand
Dim intProcessID, strComputer, colPingedComputers
Dim objComputer
strHostComputer =Inputbox("Wake Computer on another Subnet" & chr(10) & chr(13) & chr(10) & chr(13) & "Enter HOST PC Number on Remote Subnet","Input Required")
If strHostComputer = ""Then
 WScript.Echo"Host blank exiting script!"
 WScript.Quit
Endif
strMAC =Inputbox("Enter MAC of PC you want to WAKE" & chr(10) & chr(13) & chr(10) & chr(13) & "MAC can be obtained from DHCP Scope, Address Leases","Input Required")
If strMAC = ""Then
 WScript.Echo"MAC blank exiting script!"
 WScript.Quit
Endif
strIPComputer =Inputbox("Enter IP Address of Computer you want to WAKE","Input Required")
If strIPComputer = ""Then
 WScript.Echo"IP Blank will send request but can't check progress"
Endif

Const OverWriteFiles = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("C:\temp\WOL\bin\wol.exe") Then
    objFSO.CopyFolder"C:\temp\WOL" , "\\" & strHostComputer & "\C$\temp\WOL" , OverWriteFiles
Else
    Wscript.Echo"Wake on Lan File C:\temp\WOL\bin\wol.exe not found. Download from http://sourceforge.net/projects/wake-on-lan"
    WScript.Quit
EndIf


strCommand = "C:\temp\WOL\bin\wol.exe " & strMAC

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strHostComputer & "\root\cimv2")
Set objProcess = objWMIService.Get("Win32_Process")

errReturn = objProcess.Create(strCommand, null, null, intProcessID)

If errReturn = 0Then
'WScript.Echo strHostComputer &" " & strCommand & " executed with a process ID: " & intProcessID
Else
WScript.Echo strHostComputer & " " & strCommand & " not started due to error: " & errReturn
EndIf
If strIPComputer = ""Then
 WScript.Quit
Endif
' Verify Computer Availability
Wscript.Echo"Waking Remote Computer - usually takes about 1 minute"
Count = 0
DoWhile strComputerOn <> 1
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colPingedComputers = objWMIService.ExecQuery _
    ("Select * from Win32_PingStatus Where Address = '" & strIPComputer & "'")
ForEach objComputerin colPingedComputers
    If objComputer.StatusCode = 0Then
        Wscript.Echo"Remote Computer " & strIPComputer & " Powered On!!!"
        strComputerOn=1
    Else
        WScript.sleep20000
        Count = Count + 1
        If Count = 7Then
        Wscript.Echo"Can't Connect to Remote Machine WOL has failed :(" & chr(10) & chr(13) & chr(10) & chr(13) & "Or Remote Machine has new IP"
        WScript.Quit
        Endif
   EndIf
Next
Loop