Listing Exchange ActiveSync users and device information

Thursday, October 29, 2009 by BBTUNA
In How to get a list of Exchange ActiveSync users we list EAS users on Exchange 2007. Some users may have more than 1 device, or perhaps the user simply got a new smartphone and the old device partnership has not been removed.


Output from Get-ActivesyncDeviceStatistics -mailbox foo@somedomain.com:


FirstSyncTime : 12/22/2007 1:34:10 AM
LastPolicyUpdateTime : 12/22/2007 1:34:43 AM
LastSyncAttemptTime : 1/14/2008 7:45:15 AM
LastSuccessSync : 1/14/2008 7:45:15 AM
DeviceType : PocketPC
DeviceID : *******************************
DeviceUserAgent :
DeviceWipeSentTime :
DeviceWipeRequestTime :
DeviceWipeAckTime :
LastPingHeartbeat :
RecoveryPassword : ********
DeviceModel : WIZA100
DeviceIMEI : ************21900
DeviceFriendlyName : Pocket_PC
DeviceOS : Windows CE 5.2.19134
DeviceOSLanguage : English
DevicePhoneNumber : 1650*******
Identity : foo@somedomain.com\AirSync-PocketPC-*******************************

The * characters in the Identity field are for the DeviceID.

Here's a a quick code snippet (it can probably be scrubbed up a little... ) that will list users and all their devices, along with first sync and last successful sync times:

$mbx = get-casmailbox | where {$_.hasactivesyncdevicepartnership -eq $true -and $_.identity -notlike "*CAS_{*"} ; $mbx | foreach {$name = $_.name; $device = get-activesync devicestatistics -mailbox $_.identity; $device | foreach {write-host $mbx.name, $_.devicemodel, $_.devicephonenumber, $_.deviceid, $_.FirstSyncTime, $_.LastSuccessSync} }


Update: 10/2/2008:
Making it more efficient: Filtering on the server-side using -Filter
Well, the above code could be scrubbed up a little. Rather than getting all mailboxes using Get-CASMailbox and filtering them on the client-side using the Where-Objectcmdlet, a more efficient way of doing this is filtering on the server-side using the -Filter parameter, and getting only the mailboxes which have an ActiveSync device partnershp.

Yes, I've just realized HasActiveSyncDevicePartnership is in fact a filterable property, listed under Advanced Filterable Properties in Filterable Properties for the -Filter Parameter in Exchange 2007 SP1.

Here's the updated version:

$mbx = get-casmailbox -Filter {HasActivesyncDevicePartnership -eq $true -and -not DisplayName -like "CAS_{*"}; $mbx | foreach {$name = $_.name; $device = get-activesync devicestatistics -mailbox $_.identity; $device | foreach {write-host $mbx.name, $_.devicemodel, $_.devicephonenumber, $_.deviceid, $_.FirstSyncTime, $_.LastSuccessSync} }

The output looks like this:

Bharat Suneja WIZA100 16501231234 353B7ACF5014C020CE22CBF1DB7FFD92 11/5/2007 7:41:29 AM 12/20/2007 11:00:15 PM
Bharat Suneja WIZA100 16501231234 7E6B67F47DFD370E89BE13280A75EAA5 12/22/2007 1:34:10 AM 1/14/2008 7

$mbx = get-casmailbox -Filter {HasActivesyncDevicePartnership -eq $true -and -not DisplayName -like "CAS_{*"}; $mbx | foreach {$name = $_.name;$identity = $_.identity;$device = get-activesyncdevicestatistics -mailbox $_.identity; $device | foreach {write-host $mbx.name, $_.devicemodel, $_.devicephonenumber, $_.Identity, $_.deviceid, $_.FirstSyncTime, $_.LastSuccessSync} }


Posted in | 2 Comments »

Create a NFS share for VM ISO files with Windows 2003 Server R2

Thursday, October 22, 2009 by BBTUNA

If your ESX servers are not connected to network storage or if you do not have enough available space on your SAN to dedicate a sub folder of a VMFS volume for ISO files, then you can use a NFS network share to centrally store these images. Creating the NFS share can be done with many server operating systems, but did you know that Windows Server 2003 R2 has native NFS?

VMware-land.com has many “how to” VMware Tips for ESX, and the following is the instructions found there for creating a Windows 2003 R2 NFS share:


  1. On the Windows 2003 Server make sure “Microsoft Services for NFS” in installed. If not you need to add it under Add/Remove Programs, Windows
    Components, Other Network File and Print Services
  2. Next go to folder you want to share and right-click on it and select Properties
  3. Click on the NFS Sharing tab and select “Share this Folder”
  4. Enter a Share Name, check “Anonymous Access” and make sure the UID and GID are both -2
  5. In VirtualCenter, select your ESX server and click the “Configuration” tab and then select “Storage”
  6. Click on “Add Storage” and select “Network File System” as the storage type
  7. Enter the Windows Server name, the folder (share) name and a descriptive Datastore Name
  8. Once it finishes the configuration you can now map your VM’s CD-ROM devices to this new VMFS volume

Repeat steps 5 through 8 for each of your ESX servers to make the same ISO files available to all ESX hosts.

These instructions assume that you have already configured the VMkernel port group on a vSwitch for each ESX host. For instructions and information about configuring the VMKernel for NAS/NFS storage check the Storage Chapter of the ESX Server 3 Configuration Guide.

Of course, you can use the NFS share for more than just ISO file storage too. This is a good repository for patches and scripts that need to be used on all hosts. NFS also makes a good target for VM image backups too. Use some imagination and install the free VMware server on your 2003 R2 box and you have a low budget DR platform. Oh yeah, I shouldn’t forget to mention you can even run ESX VMs from NFS!

Posted in | 0 Comments »

Search for VM Snapshots from the Service Console

by BBTUNA

It may not be the fanciest of methods, but probably the quickest way to find VM snapshots is to use the ls command from the ESX Service Console. By piping the output with grep to find files with the snapshot extension, .vmsn, and using the recursive switch you can scan all the VMFS LUNs visible to an ESX host. That’s so simple it hurts!

To use the ls command to find snapshots do the following:


  1. Log in to the service console (use putty or mRemote for remote log in)
  2. Query for the snap shot files in the VMFS volumes

#ls -Ral /vmfs/volumes/* |grep .vmsn

Posted in | 0 Comments »

Script for VMware HA Feature without VirtualCenter

by BBTUNA

So, who wants free VMware High Availability? That’s the title of a post created by Leo Raikhman on his Leo’s Ramblings blog. In this post, Leo has published the steps and scripting necessary to simulate VMware’s VI3 High Availability (HA) feature. Leo’s script works without VirtualCenter (VC), so VMware customer’s who have not implemented VC can manually create “HA -like” awareness between 2 ESX hosts. If one of the ESX servers goes offline then the virtual machines (VMs) are auto restarted on the other host. Of course, the VMs must be created on shared storage for this to work.

Before considering this script as a replacement understand the major differences between VirtualCenter HA and Leo’s HA:

  • Leo’s script only works between 2 ESX hosts while VC HA can be configured with up to 32 ESX hosts as of VI 3.5 (actually using 32 host HA clusters is another topic, but it can be done)
  • Leo’s script needs the ESX Service Console as written. It would need to be ported for the RCLI to work with ESXi. VC HA works with both ESX and ESXi
  • VC provides a visual status for the health of your HA cluster via the VI Client
  • VC HA provides HA fail over capacity for more than 1 ESX host at a time

I’ve held this post in my drafts because I wanted to try this configuration myself, but alas, I have never gotten around to it. For those that can benefit from VC -less HA and give this script a test, let me (and Leo) know your results.

Leo’s post says:


“First of all lets talk about the basics of what HA actually does: if your ESX server doesn’t respond to a heartbeat for 14 seconds, the other host registers all machines and starts them up. “

Here’s the process from Leo’s Ramblings with the scripts, commands and instructions:

Create a list of the VMs on each host and copy to the other host

But there’s a few other tricks. How do you generate that other_host file? Here’s how. On each host run the following command:

vmware-cmd -l | sed ’s/\ /\\ /g’ > /root/other_host

What you’ve done is just dumped all registered machines on each host to the /root directory.

Now, scp each /root/other_host file to the other ESX server’s /etc directory.

In each /etc/other_host file, re-organize the VM order if you want them to start up differently and delete VMs that you don’t want to start up.

Create the HA script and make it executable

#!/bin/bash
if ! ping -c 14 10.8.0.1 > /dev/null; then
for $i in `cat /etc/other_host` ; do vmware-cmd -s register $i && vmware-cmd $i start ; done
fi
sleep 16
if ! ping -c 14 10.8.0.1 > /dev/null; then
for $i in `cat /etc/other_host` ; do vmware-cmd -s register $i && vmware-cmd $i start ; done
fi

Then I made it executable:

chmod a+x /usr/bin/esx_ha.sh

Here’s what the script does:

If for 14 pings, an ESX server with Service Console IP 10.8.0.1 does not reply, then, browse the contents of the file /etc/other_host, register every listed machine there on the current host (10.8.0.2) an start them up, one by one. Then it sleeps for 16 seconds, and executes the same thing again.

Seems easy enough.

Create a cron entry to start auto HA

Now we need to create a cron entry as root by running crontab -e as the root user. The screen that opens works like vi, input the following text:

MAILTO=”youremail@yourcomapny.com
* * * * * /usr/bin/esx_ha.sh

This means, that on the minute, every minute of the day, the script (which runs twice a minute) will execute and provide HA for you.

Posted in | 0 Comments »

Get a MAC address remotely

by BBTUNA
Ever been in a situation where you need to get a MAC address but don't really feel like logging into the server, wait for it to present your profile, and then open up a command prompt and finally type "ipconfig /all". Here is a trick I learned on how to do this remotely without all that of course the server and you must be online otherwise the long way it is.

1. Open up a command prompt and type
- getmac /s [servername or IP] /u [domain\username]
2. You will be prompted to enter the password for [domain\username]
3. Once you do that you will be presented with the MAC address/es.
Posted in | 0 Comments »

Regenerate SSL Certificate for ESX 3.5

Tuesday, October 20, 2009 by BBTUNA
Ever had to rename a ESX 3.5 host? You've done all the proper procedures of renaming network, hosts files, and changing your rc.conf file but now your storage doesn't recognize your new host. You've checked everything and then we you go to sign in you find out that your ssl certificate still has the old name and won't connect with the SAN array. I've recently run into that problem and here is how I fixed it.

1. Backup your ssl file to be safe.
- cp -r /etc/vmware/ssl /etc/vmware/ssl.bckp
2. After checking that the backup was indeed created, delete the rui.* files
- cd /etc/vmware/ssl
- rm rui.crt
- rm rui.key
3. Now restart hostd and ESX will regenerate the SSL cert and key using your new name.
- service mgmt-vmware restart
4. Easiest way to test if it worked is to use IE and go to https://"yourhost" and view the certificate. You should now see the new name in your issued to and issued by section of the cert.

Thats it. Any comments or question please post. Thanks.
Posted in | 0 Comments »

Failed to install the VirtualCenter Agent Service

by BBTUNA

A number of customers have been reporting the message: “Failed to install the VirtualCenter Agent Service“, when trying to connect an ESX host to virtual center, often after upgrading to ESX 3.0.2 and VC 2.0.2. In all the cases I have come across these reason seems to be that /tmp/vmware-root does not exist. This directory has to exist for the agent install process. To remedy this you can-

  1. Login to ESX Server via ssh client as root user
  2. cd /tmp
  3. mkdir vmware-root
  4. Try re-connecting the host to Virtual Center

Apparently there is a cron job that is removing this directory whenever it runs.Here is another method:

  1. Disable HA. Otherwise, the virtual machines might be forcibly powered down by step 2.
  2. At the service console, issue
    service mgmt-vmware restart
  3. At the service console, issue
    service vmware-vpxa restart
  4. Reconnect the virtual machines to VirtualCenter.
  5. Attempt to re-enable HA within VirtualCenter. If this doesn’t work, this means that vpxa did not install properly.
  6. At the service console, issue
    rpm -qa | grep vpxa
  7. At the service console, issue “rpm -e” on the rpm file that displayed in the previous command.
    rpm -e
  8. Reconnect the virtual machines in the usual manner within VirtualCenter.
  9. Re-enable HA.
Posted in | 0 Comments »

Vmotion is Disabled after upgrade

by BBTUNA

Here is a quick fix for those experiencing a problem using VMotion after upgrading from ESX Server 2.5 to ESX Server 3.5

In some cases after this upgrade is done VMotion is disabled and warm migrations are not possible. The solution is to re-enable VMotion on the host.

Re-enable VMotion on the host:

  1. Select the host in VI Client and navigate to the Networking section of its Configuration tab.
  2. Click the Properties link for the switch associated with the VMkernel port.
  3. In the switch Properties dialog box, select the appropriate network label and click Edit.
  4. Select the VMotion Enabled checkbox and click OK.
Posted in | 0 Comments »

How to root an Android G1 phone

Wednesday, October 14, 2009 by BBTUNA

First off, I take no credit for this guide, this is straight from the xda-developers forums, which is an excellent place to learn about HTC phone hacking. So let’s get started. Make sure you backup anything important on your phone as this will erase everything. There are several apps in the Market that will backup apps, SMS, and other data for you. So don’t complain if you’ve lost your data. Your contacts and email should still synch with Google once you reinstall the new OS.

If you have US-RC30/UK-RC8 or higher, you will first need to downgrade your phone to a previous version. (Skip these steps otherwise)

  1. Format your phone’s SD card to FAT32 mode:
    • Hook your phone up to your computer using a USB cable and then wait for the notification to show up in your title bar of your phone.
    • Click the notification, and then click “Mount”.
    • A new removable disk should show up on your computer. Right click it and select Format, and select FAT32 as the file system type.
  2. Download and unzip the RC29 or RC7 image file. Copy the DREAMIMG.nbh file to the SD card. (RC29 for US, RC7 is for UK)
  3. Turn the device power off.
  4. Hold Camera button, and press Power button to entry bootloader mode. You should see a gray/white screen with instructions to flash your phone with the update on your SD card. If you don’t see that, make sure you followed the instructions properly.
  5. As per the on-screen instructions, press the Power button to start upgrade procedure.DO NOT DO ANYTHING TO INTERRUPT THIS PROCESS.
  6. After it is finished, perform the restart your phone.

Once you are running RC29 firmware:

  1. Download recovery.img and copy it to your SD card (see the previous instructions on how to copy from your computer to your Phone’s SD card).
  2. Download the Hard SPL and copy the zip file to the SD card.
  3. All files must be on the root of your SD card.
  4. Restart your phone. Wait for your phone to start up fully and show the home screen.
  5. After your phone starts up, hit the enter key twice, type “telnetd” and press enter. (Yes, it will start up a contact search, don’t worry. Just type it.)
  6. Download an Android “Telnet” application from the Market and connect to localhost.
  7. If you connect successfully, you will have a root prompt “#”.
  8. Type the following into Telnet (these commands will give you root access easier in the future):
    • mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
    • cd sdcard
    • flash_image recovery recovery.img
    • cat recovery.img > /system/recovery.img

Now you have root!
Now that you have root, you will want to apply “Hard SPL” to your phone. HardSPL is what will allow you to apply flash images from other regions (like UK on US phones, and vice versa), create full backups of your phone, install the latest build from the Android source, and usually resurrect your phone if it is “bricked”. You have already downloaded the file to your SD card, so now you can apply it.

  1. Power off your phone.
  2. Start up in recovery mode by holding home and pressing power.
  3. You will now enter recovery mode. You should see an exclamation.
  4. If you do not see a menu on screen, press Alt-L to show the menu.
  5. Press Alt-S to apply the update from the SD card.
  6. After the update is complete, hold Home and press Back to restart.

And now, the last step! You are still running an old version of Android, but you want to upgrade to the latest and greatest update! You can do this, and not lose root by downloading modified versions of the updates.

Download one of the latest ROMs to install, I recommend JF1.5:

JesusFreke 1,51

Haykuro Builds

The Dude’s Cupcake 1.2 Full
The Dude’s Cupcake 1.1a Lite (No 3rdparty/dev apps/Manup Blue Theme)

You will also want to apply the latest radio update from HTC. Install the same way as the system image:

HTC Downloads Page

To install the latest build (instructions from Haykuro):

1. Gain root (follow the various threads available on the forums to accomplish this).
2. Download the latest build above.
3. Copy to your sdcard as update.zip
4. Power off your phone.
5. Hold the Home button, and power on the device. (This should send you into recovery mode).
6. Press ALT+B to create a nandroid backup (if you wish to fall back without losing any data later, if you do go back to RC33 [or any other firmware 1.0 update] you will need to reflash your radio, users have reported problems using the new radio on the old firmwares.)
7. Press ALT+W, then ALT+S.
8. wait for it to finish, then home+back.

There you have it. I hope I gave proper credit and backlinks to the awesome people that make this possible. Now you can brag about your new Cupcake and also do all the cool stuff with root, like install full Linux distros, tether your phone, and install apps on the SD card.

Posted in | 0 Comments »

How to get guest VMs MAC addresses

by BBTUNA

I noticed an IP conflict today on a windows box hosted on the ESXi. In the events viewer under system I checked the MAC address of the system trying to hijack my IP address. I wanted to find a quick way and check if this mac address is in my existing ESXi Virtual Machines or it’s outside somewhere..
I wanted to find a quick and dirty way to check this since there is number of machines on the ESXi host.
Here is what I did…

I opened VMWare VI-TOOLKIT. After I connected I decided to try some commands that I regularly use such as get-vm and get-vmguest. After I found nothing interesting I checked out the CI Toolkit Cmdlets Reference Document.

And there it was… the perfect command for what I wanted..

Get-NetworkAdapter … Wooohoo!

[VI Toolkit] C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> Get-NetworkAdapter -vm (get-vm *)|select MacAddress

MacAddress
———-
07:0c:29:11:61:6a
07:0c:29:6a:4a:db
07:0c:29:a4:ae:6f
07:0c:29:0c:c7:4c
07:0c:29:d5:8c:4f
07:0c:29:27:4d:84
07:0c:29:7c:e9:23
07:0c:29:52:52:aa
07:0c:29:eb:e3:e6
07:0c:29:17:66:50
07:0c:29:21:09:70
07:0c:29:81:89:3d
07:0c:29:0e:d6:ce
07:50:56:3f:51:02
07:0c:29:ad:60:61
07:0c:29:40:84:06
07:0c:29:40:84:10
07:0c:29:ce:89:9c
07:50:56:3f:51:01
00:1b:29:a0:ff:fe
00:1b:29:e2:ea:d5
00:1b:29:e2:ea:df
00:1b:29:e2:ea:e9
00:1b:29:07:f1:f9
00:1b:29:07:f1:03
00:1b:29:e8:8b:dd
00:1b:29:e8:8b:e7
00:1b:29:e8:8b:f1
00:50:56:3f:51:03
00:1b:29:ba:4c:b9
00:1b:29:84:2b:62
00:1b:29:2c:9d:6c
00:1b:29:7d:98:0e
00:1b:29:6a:1a:a5
00:1b:29:5a:82:cf
00:1b:29:26:23:bf
00:1b:29:df:87:1c

The MAC I was looking for was not here but this is a proof that none of the machines in my control is attempting the hijacking.

Posted in | 0 Comments »

About Me