Tuesday, February 24, 2009

OCS, WMI and PowerShell

This past week, I was teaching OCS Voice Ignite in Munich and a colleague (superstar Robin Edwards). During the week, we chatted about how to configure OCS’s Address Book service. This is a topic that comes up a lot in our OCS training, especially as the Address Book seems to be one of the key troubleshooting issues our delegates encounter.

As it turns out, you cannot do much with the GUI. There’s nothing there to enable you to do much more than view SOME of the settings. For example, by default, OCS ABS keeps 30 days worth of delta address books. If you login to Office Communicator, OC will download only the deltas since the last time you logged in, up to a certainly value – by default 30 days. This is a great feature for very large address books that don’t change a lot week to week.

The problem is, you can’t see this value in the GUI, nor can you set it. To view or change this, you need to use WMI in a direct way. Which leaves you three options: WBEMTest, VBS, or PowerShell. For most admins, WBEMTest is way too ugly and unfriendly and that probably is true for VBS. But PowerShell makes it very, very easy (assuming you know PowerShell of course).

The key settings for the Address Book Server are found in the WMI Class MSFT_SIPAddressBookSettings. This class is defined in MSDN at http://msdn.microsoft.com/en-us/library/bb632067.aspx.

This class has some useful properties, including:

DaysToKeep – specifies the number of days to keep the delta data files. The default is 30.

ExternalURL - An HTTPS URL that specifies the external location for address book file downloads

InternalURL - An HTTPS URL that specifies the internal location for address book file downloads.

MaxDeltaFileSizePercentage - The maximum percent of change for which a delta file is created. A delta file is not created if the percent of change is greater than this number. Multiply the value by 0.01 to derive the percentage. The minimum value for this property is 0 and the maximum value is 9999 (99.99%). The default value is 1250 (12.5%).

OutputLocation - Specifies the directory in which the files are stored.
PartitionOutputByOU - Controls whether data is partitioned by organization unit (OU).
RunTime - Specifies the service start time. The minimum value for this property is 0 and the maximum value is 2359. The default value is 130.

SynchronizeNow - When true, triggers the Address Book Server to perform a synchronization pass.

SynchronizePollingIntervalSecs - Specifies the number of seconds between checks for synchronization. The minimum value for this property is 5 and the maximum value is 9999.

UseNormalizationRules - Controls whether normalization is performed.

So much for what it does, now to how to do it with OCS R2. To get this class, using Standard Edition, you just use:

Get-WMIObject –Class MSFT_SipAddressbookSetting

However, using EE, it’s a bit more complex and you have to use a slightly different variation on the Get-WMIObject sytax, as follows:

PS C:\foo> gwmi -query "select * from MSFT_SipAddressBookSetting where backend='dc1'" -computer ocs-ee

Backend : dc1
DaysToKeep : 30
ExternalURL :
IgnoreGenericRules : False
InstanceID : {D265A402-BD08-4BCB-BEB3-CC7AFBD47C08}
InternalURL :
https://Cookham.gktrain.net/Abs/Int/Handler
MaxDeltaFileSizePercentage : 1250
OutputLocation : \\ocs-ee\absfiles
PartitionOutputByOU : False
RunTime : 130
SynchronizeNow : False
SynchronizePollingIntervalSecs : 300
UseNormalizationRules : True
WebServiceEnabled : True

So to make some changes, you could do something like this:

PS C:\foo> $abs = gwmi -query "select * from MSFT_SipAddressBookSetting where backend='dc1'" -computer ocs-ee
PS C:\foo> $abs.daystokeep = 45
PS C:\foo> $abs.runtime = 0230
PS C:\foo> $result = $abs.put()

PS C:\foo> gwmi -query "select * from MSFT_SipAddressBookSetting where backend='dc1'" -computer ocs-ee

Backend : dc1
DaysToKeep : 45
ExternalURL :
IgnoreGenericRules : False
InstanceID : {D265A402-BD08-4BCB-BEB3-CC7AFBD47C08}
InternalURL : https://Cookham.gktrain.net/Abs/Int/Handler
MaxDeltaFileSizePercentage : 1250
OutputLocation : \\ocs-ee\absfiles
PartitionOutputByOU : False
RunTime : 230
SynchronizeNow : False
SynchronizePollingIntervalSecs : 300
UseNormalizationRules : True
WebServiceEnabled : True

And finally – a bit tip of the hat to superstar Robin Edwards who showed me this class last week. Thanks Rob – you rock!

Technorati Tags: ,,

2 comments:

Adam Gent said...

Hi Thomas,

There is a small typo in
$result = abs.put()

it should be

$result = $abs.put()

Though I would just post this in case anyone else runs into this, it took me a while to figure this out not really knowing PowerShell.

Thomas said...

Adam: thanks for the heads up - bug fixed!