Active Directory Migrations: Assorted Lync Stuff

Wow, so it’s been a whole 3 months since I’ve posted. Can you tell I got deep into actually doing migrations rather than talking about it? It took a little longer than I’d hoped – mainly due to scheduling – but we managed to finish the migrations. I personally migrated a little over 2,000 people. Due to our migration windows I never did more than 150 people at a time, but I was surely itching to.

These next couple of scripts are Lync related. Not too much involved in them, mainly creating the remote session and then running a quick command. Note that we installed the Lync module on our ADMT server, but for some reason some of the commands don’t work natively so we had to do some thru remote pssessions and some thru the module


##call include file.
## this is just in case we forgot to call it before
. .\params.ps1

##Create Sessions
##The usual pssession, just pointing to the Lync server in the source domain and using our source credentials
$LyncSessionSource=New-PSSession -connectionuri $LyncURISource -credential $RemoteCredentials

## Import our include file
$import=import-csv $importfile

##Source side disable-csuser
##Import the session, and then for each item in the include file, disable them for Lync in the source domain.
##Lync uses display name so we have to make sure that's in our include file
import-pssession $LyncSessionSource
foreach ($item in $import){
 write-host "Disabling Lync for " $item.olddisplayname -foregroundcolor yellow
 disable-csuser -identity $item.olddisplayname
}

## Let's clean up our session
remove-pssession $LyncSessionSource

Our next script is basically the same, but opposite. Let’s enable them for Lync in the target domain


##call include file
. .\params.ps1

##Create Sessions
$LyncSession=New-PSSession -connectionuri $LyncURI -credential $LocalCredentials

##Import
$import=import-csv $importfile

##Target side enable cs-user
##Import the session, then go thru the input file
##Since we changed the displayname of users as part of the process we had to account for that in the include file
## The rest of the commands are Lync specific. When you enable you have to specify registrar pool and address type
import-pssession $LyncSession

foreach ($item in $import){
 if ($item.smtp){
 enable-csuser -identity $item.displayname -registrarpool $registrarpool -sipaddresstype EmailAddress
 write-host "Enabling Lync for: " $item.displayname -foregroundcolor yellow
 }
}

##Let's clean up after ourselves
remove-pssession $LyncSession

This one is basically the same as the previous, but we have to set options for the users that can’t be set in the enable command. We’re setting the LineURI (i.e. telephone number) and turning on Enterprise Voice.


##call include file
. .\params.ps1

##Create Sessions
$LyncSession=New-PSSession -connectionuri $LyncURI -credential $LocalCredentials
$import=import-csv $importfile

##Target side enable cs-user
import-pssession $LyncSession

foreach ($item in $import){
 if ($item.LineURI){
 set-csuser -identity $item.displayname -EnterpriseVoiceEnabled $true -LineURI $item.LineURI
 write-host "Setting EV and LineURI for: " $item.displayname -foregroundcolor yellow
 }
}
## let's clean up, shall we?
remove-pssession $LyncSession

This last one grants the voice policy and the mobility policy, if applicable. This is using the Lync powershell modules on the ADMT server


$Importfile="\\omacsgiadmt01\d$\Migration\admtincludes\UserIncludes.csv"
$import=import-csv $importfile

import-module Lync

foreach ($item in $import){
 grant-csvoicepolicy -identity $item.displayname -policyname $item.CSVoicePolicy
 write-host "Granting CSVoice: " $item.displayname -foregroundcolor yellow
 $LM=$item.LyncMobility.ToUpper()
 if ($LM -eq "YES"){
 Grant-CsMobilityPolicy -identity $item.DisplayName -Policyname "CSGI Mobility"
 write-host "Granting CSMobility: " $item.displayname -foregroundcolor yellow
 }
}

That’s it for Lync!

Advertisements

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