Often enough I get locked files and I have 32 hosts in my cluster so to find the lock I typically
will run vmkfstools -D against the flat file to reveal the mac of the host locking it.
Lock [type 10c00001 offset 79308800 v 9545, hb offset 4063232
gen 383, mode 2, owner 00000000-00000000-0000-000000000000 mtime 26534301
num 3 gblnum 0 gblgen 0 gblbrk 0]
RO Owner[0] HB Offset 3469312 54d3ab21-8e99bc6c-6190-6cc2172a3340
RO Owner[1] HB Offset 3764224 54d3bee6-c3760cb4-f4a6-9cb65492e358
RO Owner[2] HB Offset 3567616 54da4e83-ce3f7196-3c91-984be1000bea
I then take the following script I stole from somebody off the net and plug in my mac in the desired format and this reveals my host name.
connect-viserver VC
#Enter which cluster the locked file is within
$cluster = Read-Host "Enter Cluster"
#Enter MAC Address of host (00:00:00:00:00:00 format)
$MAC = Read-Host "Enter Desired MAC (00:00:00:00:00:00 format)"
get-cluster $cluster | get-vmhost | Get-VMHostNetworkAdapter | where {$_.Mac -match "$MAC" } | select-object VMHost, Name, MAC, IP, BitRatePerSec | ft -autosize
disconnect-viserver VC -confirm:$false
The problem is I would like to just to copy/paste from Putty instead of having to add the : in the proper places (ease of use, lazy, etc..)
I found this script to do the conversion
$mac = "001122334455"
$mac = $mac.insert(3,":")
$mac = $mac.insert(6,":")
$mac = $mac.insert(9,":")
$mac = $mac.insert(12,":")
$mac = $mac.insert(15,":")
write-host "sh mac address-table address $mac"
but I have no ideal how to combine the two.
Can someone who actually knows how to script and not just steal of the net help me out?
Thank you,
-Glenn