|
Replies:
4
-
Pages:
1
-
Last Post:
Jul 15, 2010 3:12 PM
by: cjohnsto
|
|
|
Posts:
1
Registered:
11/10/09
|
|
|
|
Script for OCS (Office Communicator Server)
Posted:
Nov 10, 2009 1:57 PM
|
|
|
Hi All,
I need some help with changing the sip address in Office communicator.
This week there was a change in our business to change email format on exch7... now there is a mismatch for the OCS..
this is based on a location so all users are effected currently. The old format was jblog@domain.com.au, the new format is joe.blog@domain.com.au so it was the alias that changed not the domain..
now we need to change the sip from sip.jblog to sip.Joe.Blog and relate the to domain.com.au
Can someone assist me on this..
Regards Daz
|
|
|
Posts:
2
Registered:
11/10/09
|
|
|
|
Re: Script for OCS (Office Communicator Server)
Posted:
Nov 11, 2009 5:12 PM
in response to: DarrinjOwen
|
|
|
This is definitely scriptable, in a variety of ways.
Assuming you wanted to build the e-mail address from the AD info, you could build that via First and Last name, then you’d do the following: 1. Use the $user.UserDN value (which gives the distinguished name of the user in AD)
2. Issue an LDAP query to retrieve the user object (given the above DN)
3. Use the AD attributes corresponding to First name and Last name (or sign-in address) to update the E-maill address and/or SIP URI.
Assuming the e-mail addresses have already been built, and you just want to make the SIP URI match, it would be simpler: Just copy the e-mail attribute contents to the SIP URI.
This should get you started, though it isn't a complete solution for your question. It's from a script that modifies the SIP URI, but by changing the domain, not the user name:
Prereqs - Need the OCS Admin tools installed on the machine (or run this from the front end server).
$SIPDOMAINTOMODIFY = “domain1.com” $NEWPODSIPDOMAIN = “domain2.com”
function ModifyUsersSipUri { Write-Host -foregroundcolor Green "Reassigning user accounts..."; $users = gwmi -class MSFT_SIPESUserSetting; foreach($user in $users) { $sipUri = $user.PrimaryURI; $newSipUri = $sipUri.Replace($SIPDOMAINTOMODIFY, $NEWPODSIPDOMAIN); $user.PrimaryURI = $newSipUri; Write-Host "Changing SIP Uri for:" $user.DisplayName "($sipUri --> $newSipUri)"; $output = $user.Put(); } Write-Host ""; }
|
|
|
Posts:
2
Registered:
11/10/09
|
|
|
|
Re: Script for OCS (Office Communicator Server)
Posted:
Nov 12, 2009 11:51 AM
in response to: DarrinjOwen
|
|
|
Of course, IANAD (I am not a developer), though I was, many years ago.
Here's a further (untested) refinement that one of my coworkers (who *is* a developer) dashed off:
Write-Host -foregroundcolor Green "Reassigning user accounts..."; $users = gwmi -class MSFT_SIPESUserSetting; foreach($user in $users) { $userDN = $user.UserDN; $userADObjectQuery = "LDAP://" + $userDN; $userADObject = [ADSI]$userADObjectQuery; $newSipUri = $userADObject.mail; $user.PrimaryURI = $newSipUri; Write-Host "Changing SIP Uri for:" $user.DisplayName "($sipUri --> $newSipUri)"; $output = $user.Put(); } Write-Host "";
|
|
|
Posts:
1
Registered:
7/13/10
|
|
|
|
Re: Script for OCS (Office Communicator Server)
Posted:
Jul 13, 2010 9:37 AM
in response to: DarrinjOwen
|
|
|
Hi, I've tried running this script and it does make any changes, just gives an error of:
Exception calling "Put" with "0" argument(s): "" At C:\change_sip.ps1:16 char:44 + $output = $user.Put <<<< (); + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
Is anyone able to help please?
|
|
|
Posts:
6
Registered:
3/14/07
|
|
|
|
Re: Script for OCS (Office Communicator Server)
Posted:
Jul 15, 2010 3:12 PM
in response to: GuyW
|
|
|
I am fairly certain that you need to prefix the new SIP value with the four characters "SIP:".
Add this before this line "$user.PrimaryURI = $newSipUri": > if ($newSipUri.Substring(0,4).toupper() -ne 'SIP:') {$newSipUri = "SIP:$newSipUri"}
If that does not work, I've seen the .Put method throw this exception for one of three other reasons: 1) If the value of the OCS user WMI attribute you are trying to set (in this case the userDN) is not valid. Is the domain part of the new user SIP registered as valid OCS domain? In the OCS management console right-click on the Forest | Global Properties | General tab. Do you have the new SIP domain listed there? 2) Sometime the .Put() method needs to be piped to out-null() - can't remember why. Try changing this line to the following: > $output = $user.Put() | out-null 3) In PowerShell v1.0, there was a WMI bug whereby if you were accessing classes not in the default cimv2 namespace, the first method call through an error. MSFT_SIPESUserSetting is in the default namespace so that should not be an issue. Here is a powershell script I wrote to enable an OCS user that might help you: http://www.insideocs.com/Tools/EnabledOCSUser.ps1 from my blog post "Provisioning OCS From the Command Line" (http://blog.insideocs.com/2009/01/16/189/).
Hope that helps, Curtis
|
|
|
|
Legend
|
|
MVP: 2501
+
pts
|
|
Guru: 2001
- 2500
pts
|
|
Expert: 751
- 2000
pts
|
|
Enthusiast: 31
- 750
pts
|
|
Novice: 0
- 30
pts
|
|
Moderators
|
|
Helpful answer
(5 pts)
|
|
Answered
(10 pts)
|
|