Home > OCS 2007 / Lync 2010, Powershell > OCS 2007 R2: Enable a user with powershell

OCS 2007 R2: Enable a user with powershell

In this post I will show you how you can enable a useraccount with Powershell in OCS 2007 R2. Yes there isn’t a powershell CMD-let available in OCS 2007 R2 but there are some nice OCS Powershell example Functions available on the companion CD of the OCS 2007 R2 resource KIT book.

Download the following two files from the companion CD and place them in a directory on your Edge/Standard edition server:

  • OCS-All.ps1
  • ocsTypes.format.ps1xml

First modify the first file OCS-All.ps1 based on http://support.microsoft.com/kb/969486/en-us
The Function “Get-OCSUser” must be modified because it could generate errors when your create a new user(probably on line 103).

if (($URI -eq “%”) -or ($URI=”*”)) {$uri=$null}  #old
if (($URI -eq “%”) -or ($URI –eq “*”)) {$uri=$null} #correct

You will now be able to load the OCS functions in the Powershell console. It may be necessary to run first the “set-ExecutionPolicy RemoteSigned” before you can load the functions.

[PS] C:\Powershell>.  .\OCS-All.ps1

You can now get all OCS commands via:

[PS] C:\Powershell>get-ocsfunction

Create a new OCS user:
Before we can create a new OCS user we must retrieve the correct user “distinguished name” and Pool “distinguished name”. In the example below I put them in two variables because these names are quite long. I make also use of the “Quest Active roles Management” shell to retrieve the DN name via the “Get-QADuser” command. Get-OCSpool is also one of the example functions.

[PS] C:\Powershell>$userdn = Get-qaduser ocsuser1 | foreach {$_.DN}
[PS] C:\Powershell>$pooldn = get-ocspool | foreach {$_.pooldn}

The next step is to create a new OCS user via the “New-OcsUser” function:

[PS] C:\Powershell>New-OcsUser -uri “sip:name@example.com” -user $userdn -homeServer $pooldn



Account is now enabled for OCS 2007 R2 with powershell! A more detailed view of the user can be accomplished via get-ocsuserdetail:

[PS] C:\Powershell>Get-OCSUserDetail -condition “PrimaryURI like ‘SIP:ocsuser1%'”

Complete list of functions:

Enable-ExchUmForOcsUser
Get-OCSADContainer
Get-OCSEdgeAvAuthCert
Get-OCSEdgeConferencingExternalCert
Get-OCSEdgeFederationDenied
New-OCSEdgeFederationDenied
Remove-OCSEdgeFederationDenied
Get-OCSEdgeFederationExternalCert
Get-OCSEdgeFederationInternalCert
Export-OCSEdgeFederationPartner
Get-OCSEdgeFederationPartner
Import-OCSEdgeFederationPartner
New-OCSEdgeFederationPartner
Remove-OCSEdgeFederationPartner
Get-OCSEdgeIMProvider
New-OCSEdgeIMProvider
Remove-OCSEdgeIMProvider
Update-OCSEdgeIMProvider
Get-OCSEdgeInternalDomain
New-OCSEdgeInternalDomain
Remove-OCSEdgeInternalDomain
Get-OCSEdgeInternalServer
New-OCSEdgeInternalServer
Remove-OCSEdgeInternalServer
Get-OCSErrorEvent
Get-OCSFunction
Get-OCSGlobalUCSetting
Get-OCSInstalledService
Choose-OCSLocationProfile
Get-OCSLocationProfile
New-OCSLocationProfile
Remove-OCSLocationProfile
Choose-OCSMediationServer
Set-OCSMediationServerPlusSign
Get-OCSMediationServerSetting
Choose-OCSMeetingPolicy
Get-OCSMeetingPolicy
New-OCSMeetingPolicy
Remove-OCSMeetingPolicy
Update-OCSMeetingPolicy
Choose-OCSNormalizationRule
Remove-OCSNormalizationRuleFromOCSLocationProfile
Get-OCSNormalizationRule
New-OCSNormalizationRule
Remove-OCSNormalizationRule
Add-OCSNormalizationRuleToOCSLocationProfile
Update-OCSNormalizationRule
Choose-OCSPhoneRoute
Get-OCSPhoneRouteForNumber
Get-OCSPhoneRouteForOCSPhoneRouteUsage
Get-OCSPhoneRouteForOCSUser
Get-OCSPhoneRoute
New-OCSPhoneRoute
Remove-OCSPhoneRoute
Update-OCSPhoneRoute
Choose-OCSPhoneRouteUsage
Get-OCSPhoneRouteUsageForOCSUCPolicy
Remove-OCSPhoneRouteUsageFromOCSPhoneRoute
Remove-OCSPhoneRouteUsageFromOCSUCPolicy
Get-OCSPhoneRouteUsage
New-OCSPhoneRouteUsage
Remove-OCSPhoneRouteUsage
Add-OCSPhoneRouteUsageToOCSPhoneRoute
Add-OCSPhoneRouteUsageToOCSUCPolicy
Get-OCSPICUserCount
Choose-OCSPool
Get-OCSPool
Start-OCSReplication
Get-OCSSchemaVersion
Get-OCSSIPDomain
New-OCSSIPDomain
Remove-OCSSipDomain
Get-OCSSipRoutingCert
Get-OCSTrustedService
Choose-OCSUCPolicy
Get-OCSUCPolicyForOCSUser
Get-OCSUCPolicy
New-OCSUCPolicy
Remove-OCSUCPolicy
Update-OCSUCPolicy
Get-OCSUserDetail
Export-OCSUser
Get-OCSUser
Import-OCSUser
New-OCSuser
Remove-OCSUser
Update-OCSUser
Get-OCSWarningEvent
Get-OCSWindowsService
Start-OCSWindowsService
Stop-OCSWindowsService

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: