Lync Data Collection in xml

########################################################################
# Author: Paul B
# Purpose: Script to Collect Lync Data
# Version: 1.0
# 03/02/2013 – Release 1.0
#Change
# Instructions
# Edit the below variables to match your requirements
#Purpose
#Collects Lync Config Data and Dumps in c:\Backup\LyncData
########################################################################


cd $env:UserProfile
Import-Module ‘C:\Program Files\Common Files\Microsoft Lync Server 2010\Modules\Lync\Lync.psd1’
$filename = “c:\backup\{0:yyyy.MM.dd-HH.mm}-CSconfig.zip” -f (Get-Date)
$filename1 = “c:\backup\{0:yyyy.MM.dd-HH.mm}-LISconfig.zip” -f (Get-Date)
export-csconfiguration -Filename $filename -Force:$True
export-cslisconfiguration -Filename $filename1
New-Item c:\Backup\LyncData -type directory -force
Get-CsDialPlan | Export-Clixml -path c:\Backup\LyncData\DialPlan.xml
Get-CsVoiceNormalizationRule | Export-Clixml -path c:\Backup\LyncData\VoiceNormalizationRule.xml
Get-CsOutboundTranslationRule | Export-Clixml -path c:\Backup\LyncData\OutBoundRules.xml
Get-CsVoicePolicy | Export-Clixml -path c:\Backup\LyncData\VoicePolicy.xml
Get-CsVoiceRoute | Export-Clixml -path c:\Backup\LyncData\VoiceRoute.xml
Get-CsPstnUsage | Export-Clixml -path c:\Backup\LyncData\PSTNUsage.xml
Get-CsVoiceConfiguration | Export-Clixml -path c:\Backup\LyncData\VoiceConfiguration.xml
Get-CsTrunkConfiguration | Export-Clixml -path c:\Backup\LyncData\TrunkConfiguration.xml
Get-CsDialInConferencingAccessNumber | export-Clixml -path c:\Backup\LyncData\DialInConf.xml
Get-CsUnassignedNumber | Export-Clixml -path c:\Backup\LyncData\UnassignedNumber.xml
Get-CsUser | select-object DisplayName,LineUri,EnterpriseVoiceEnabled | export-csv -path c:\Backup\LyncData\LyncUsers.csv
Get-CsLocationPolicy | export-Clixml -path c:\Backup\LyncData\LocationPolicy.xml
Get-CsRgsQueue | Export-Clixml -path c:\Backup\LyncData\RGSQueues.xml
Get-CsSimpleUrlConfiguration | Export-Clixml -path c:\Backup\LyncData\SimpleUrl.xml
Get-CsMcxConfiguration | Export-Clixml -path c:\Backup\LyncData\MCX.xml
Get-CsSipDomain | Export-Clixml -path c:\Backup\LyncData\SipDomain.xml
Get-Cstopology | Export-Clixml -path c:\Backup\LyncData\topology.xml
Get-CsTrustedApplication | Export-Clixml -path c:\Backup\LyncData\TrustedApplication.xml
Get-CsUserDatabaseState | Export-Clixml -path c:\Backup\LyncData\UserDatabaseState.xml
cd\

Posted in Data Collection | Leave a comment

AD Health Check

I have been using this from before my blogging days so cant remember who the original author was, but a big thanks to you anyway

AD Health Check
Dumps results in c:\adHealth.txt

####################################################################### 
@echo off
echo Active Directory Health Diagnostic, v1.1 echo ………………………………….
echo Running dcdiag /v…..
dcdiag /v >> c:\adHealth.txt
echo Running dcdiag /test:DNS /DNSALL (This test may take a few minutes)…..
dcdiag /test:DNS /DNSALL /e /v >> c:\adHealth.txt echo Running dcdiag /test:DcPromo /e /v…..
dcdiag /test:DcPromo /e /v >> c:\adHealth.txt echo Running dcdiag /test:RegisterInDNS…..
dcdiag /test:RegisterInDNS >> c:\adHealth.txt echo Running netdiag.exe /v…..
netdiag.exe /v >> c:\adHealth.txt
echo Running netsh dhcp show server…..
netsh dhcp show server >> c:\adHealth.txt echo Running repadmin /showreps…..
repadmin /showreps >> c:\adHealth.txt
echo Running repadmin /replsum /errorsonly…..
repadmin /replsum /errorsonly >> c:\adHealth.txt echo ………………………………….
echo Diagnostic Completed Successfully…
echo view results in C:\adHealth.txt
pause
echo ………………………………….
echo ………………………………….
echo ………………………………….
echo General Health Ratio (FAILS/PASSES) echo This is only a general indication of AD Health, please review the results in C:\adHealth.txt!
echo ………………………………….
echo NUMBER OF FAILS
find /c /i “fail” c:\adHealth.txt
echo ………………………………….
echo NUMBER OF PASSES
find /c /i “pass” c:\adHealth.txt
pause

#################################################################################################

Posted in AD Health Check | Leave a comment

Lync Performance Counters

By using the Lync Shell command CSWindowsService one is able to grab a snapshot of all the current call and conferencing activity.

Command
Get-CsWindowsService

Output


This is by no means all the Lync Counters..

If you wanted to see all the Lync Counters use the following command:

Get-Counter -ListSet “LS:*” | Select-Object

Posted in Counters, CSWindowsService, Performance, Powershell, PS | Leave a comment

RGS Business Hours

Changing RGS Business hours
Below script used to change (or ADD) the business hours to 7:30 – 17:00 Monday to Friday

########################################################################
# Author: PB
# Purpose: Script to Changing RGS Business hours
# Version: 1.0
# 03/04/2013 – Release 1.0
#
# Instructions
# Edit the below variables to match your requirements
#
########################################################################

$weekday = New-CsRgsTimeRange -Name “Service Desk – 7 to 7” -OpenTime “7:00” -CloseTime “19:00”

New-CsRgsHoursOfBusiness -Parent “service:ApplicationServer:LXLLS2013FE.lexel.local” -Name “Service Desk – 7 to 7” -MondayHours1 $weekday -TuesdayHours1 $weekday -WednesdayHours1 $weekday -ThursdayHours1 $weekday -FridayHours1 $weekday

Posted in Business Hours, RGS | Leave a comment

Import Lync Users from CSV

Import Lync Users from CSV.

NOTE

In the CSV the following headers need to be present:-

Column Header
Description
ADUsername
Valid AD User Name
Pool
The Lync Pool the user will be assigned to
LineUri
This must be in the format tel:+xxxxx
ClientPolicy
Get-CsClientPolicy to see what’s configured or set to add new PS only
ConferencePolicy
Get-CsConferencingPolicy to see, add from Control Panel or PS
DialPlanpolicy
Get-CsDialPlan to see, add from Control Panel or PS
Voicepolicy
Get-CsVoicePolicy to see, add from Control Panel or PS
ExternalAccessPolicy
Get-CsExternalAccessPolicy to see, add from Control Panel or PS



########################################################################
# Author: Paul B
# Purpose: Script to Import Lync Users from CSV
# Version: 1.0
# 02/02/2013 – Release 1.0
#Change
# Instructions
# Edit the below variables to match your requirements
#
########################################################################

#Variables

$File = “C:\Lync\Scripts\importusers\LyncUsers.csv”
$Log = New-Item -ItemType File -Path “C:\Lync\Scripts\importusers\userlog.txt” -Force

#Import csv

$usercsv = Import-Csv -path $file -Delimiter ‘,’

#Check if user file is empty.

if ($Usercsv -eq $null)
{
 write-host “No Users Found in Input File”
 exit 0
}

#Get total number of users in CSV file and begin processing.

$count = $Usercsv | Measure-Object | Select-Object -expand count


Write-Host “Found ” $count “Users to import.”

Write-Host “Processing Users…..`n”
$index = 1

ForEach ($user in $usercsv)


{


Write-Host “Processing User ” $index ” of ” $count

$Fullname = $User.ADUsername
$aduser = get-csaduser -Identity $Fullname

#Check if user is in AD.  Log if they are NOT.

if ($aduser -eq $null) {
$notinad = $true
Write-Host “User ” $Fullname ” is not in AD.  Double check spelling, etc.” -Foregroundcolor Red
Add-Content -Path $Log -Value “$($Fullname) is not in AD.  Double check spelling, etc.”
}

else {

$notinad = $false
}

#If user is in AD check if enabled in Lync and log if enabled.

if ($aduser.Enabled) {
Write-Host $User.ADUsername”is already enabled in Lync, skipping.”  -Foregroundcolor Yellow
Add-Content -Path $Log -Value “$($Fullname) is already enabled in Lync.”
}

#User not enabled in Lync

else {
Write-Host “Adding user ” $User.ADUsername -Foregroundcolor Green
                Enable-CsUser -Identity $User.ADUsername -RegistrarPool $user.Pool -SipAddress $user.sipaddresstype emailaddress

#Check if last command failed.  If it does, log it.

if(!$?) {
Add-Content -Path $Log -Value “$($Fullname) not enabled.  $(Get-Date)$($error[0])”
continue
}
#Enable for EV and Add Line URI
Set-csuser -identity $User.ADUsername -enterprisevoiceenabled $true -lineuri $user.LineURI
#Check if last command failed.  If it does, log it.
if(!$?) {
Add-Content -Path $Log -Value “$($Fullname) not enabled.  $(Get-Date)$($error[0])”
continue
}
#CSClientPolicy
Grant-csclientpolicy -Identity $User.ADUsername -PolicyName $user.clientpolicy
#Check if last command failed.  If it does, log it.
if(!$?) {
Add-Content -Path $Log -Value “$($Fullname) not enabled.  $(Get-Date)$($error[0])”
continue
}
#Conferencing Policy
Grant-csconferencingpolicy -Identity $User.ADUsername -PolicyName $user.conferencepolicy
#Check if last command failed.  If it does, log it.
if(!$?) {
Add-Content -Path $Log -Value “$($Fullname) not enabled.  $(Get-Date)$($error[0])”
continue
}
#Dial Plan
Grant-CsDialPlan -Identity $User.ADUsername -PolicyName $user.DialPlanpolicy
#Check if last command failed.  If it does, log it.
if(!$?) {
Add-Content -Path $Log -Value “$($Fullname) not enabled.  $(Get-Date)$($error[0])”
continue
}
#Voice Policy
Grant-CsVoicePolicy -Identity $User.ADUsername -PolicyName $user.Voicepolicy
#Check if last command failed.  If it does, log it.
if(!$?) {
Add-Content -Path $Log -Value “$($Fullname) not enabled.  $(Get-Date)$($error[0])”
continue
}
#External Access Policy
grant-csexternalaccesspolicy -Identity $User.ADUsername -PolicyName $user.externalaccesspolicy
#Check if last command failed.  If it does, log it.
if(!$?) {
Add-Content -Path $Log -Value “$($Fullname) not enabled.  $(Get-Date)$($error[0])”
continue
}
    }
$index++
}

Write-Host “Importing of Lync users from CSV completed!”

Write-Host “”
Write-Host “”
Write-Host “”

update-csuserdatabase -verbose

sleep -seconds 300
update-csaddressbook -verbose




Posted in Import Lync Users from CSV | Leave a comment