Archive for February, 2011

OCS 2007 R2: Get OCS contacts with Powershell and WMI

February 22, 2011 3 comments

It is apparently also possible to manage OCS tasks by using WMI and Windows PowerShell. In this post I will cover how to get contacts of a specific user account. This task is unfortunately not possible via the OCS GUI Console. This is in analog to my previous post where I already covered how to extract a contactlist via the “Dbimpexp.exe” which is included in the OCS 2007 Resource Kit.

Get OCS contacts with Powershell and WMI:

$User = Get-WmiObject -Query "Select * from MSFT_SIPESUserSetting where PrimaryURI = ''"
$UserInstanceID = $User.InstanceID
$Contacts = Get-WmiObject -Query "Select * from MSFT_SIPESUserContactData where UserInstanceID = '$UserInstanceID'"
$displaycontacts = $Contacts | select SIPURI
Write-Output $displaycontacts

First you need to find the corresponding UserInstanceID of the SIP URI via the  MSFT_SIPESUserSetting WMI Class. In the second part of the script you can get the contacts from the MSFT_SIPESUserContactData Class with the UserInstanceID.


Get also the OCS Powerpack from PowerGUI to easily view the OCS WMI Classes:

Other interesting scripts can be found in the underneath technet blog:


OCS 2007 R2: Get more info about the error codes

February 17, 2011 Leave a comment

You can retrieve more info about hexadecimal/decimal error codes in OCS with the LCSError.exe which is included in the Resource Kit tools for Office Communications Server 2007.

  • Open Command prompt
  • Navigate to: C:\Program Files\Microsoft Office Communications Server 2007 R2\ResKit
  • Execute:

LCSError.exe “errorcode”

For example:

0x8007274C ->  (System) A connection attempt failed because the connected party
did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

0x80072746 ->  (System) An existing connection was forcibly closed by the remote host.

This tool can be run on all Office Communications Server 2007 roles.

Categories: OCS 2007 / Lync 2010

OCS 2007 R2: Get contact list for a singel user account

February 16, 2011 1 comment

The OCS 2007 R2 database import and export tool “Dbimpexp.exe” is used to import or export userdata. In this article I will describe how to get a contact list for a single user account from the SQL database on the Standard Edition server. This tool can export userdata to XML files on a specified location. Dbimpexp.exe is installed on the server computer under the Common Files for the Communications Server installation folder. The default is: <drive>: \Program Files\Common Files\Microsoft Office Communications Server 2007 R2\Support.

  1. Open Command Prompt
  2. Navigate to “C:\Program Files\Common Files\Microsoft Office Communications Server 2007 R2\Support”
  3. execute:

dbimpexp.exe /hrxmlfile:”c:\temp\username.xml” /restype:user /

/hrxmlfile: specify the location of the xml file
/user: specify the SIP URI of the user

For the Enterprise Edition (specify the sql server):

dbimpexp.exe /hrxmlfile:”c:\temp\username.xml” /sqlserver:<sql server host name> /restype:user /

Categories: OCS 2007 / Lync 2010