Thursday, July 28, 2011

Get OCS Client Version Script

This script uses the OCS 2007 R2 Resource Kit (didn't test with OCS 2007) to query its database and check the user’s version of the client they are using to connect to OCS.

The script reads a list of users to query from the UsersList.csv file and then queries one by one using the DBAnalyze tool from the Resource Kit (please update the path accordingly).

$users = Get-Content D:\UsersList.csv
cd "C:\Program Files\Microsoft Office Communications Server 2007 R2\ResKit"

ForEach ($user in $users)
  $strCmd = ".\DBAnalyze.exe"
  $strParams = "/Report:user /User:$user > D:\OCSUserReport.txt"
  $strExec = "$strCmd $strParams"
  Invoke-Expression $strExec

  # Get the user's version
  $strVersion = Select-String -Path D:\OCSUserReport.txt -Pattern "Client version"

  # Print the user's client version
  If ($strVersion -ne $NULL)
    Write-Host "$user $strVersion"

cd D:\
Remove-Item D:\OCSUserReport.txt

No comments:

Post a Comment