Populate ProxyAddresses when migrating to Office 365

We’ve had a couple of customers with a hosted Lync/SfB installation and Exchange Online where the users don’t have the ProxyAddresses field declared, and as a result, the users have EWS integration problems. The most noticeable for users is that their conversation history folder doesn’t capture history beyond the point where they migrate to Exchange Online.

This may be fairly unique to us, as we build hosted Skype for Business environments which ADSync user details back from the customer’s onsite active directory to ours. When they sync to 365, they’ll generally do it from their AD as well, so there’s a bit of a disconnect.

To fix the problem, either manually go through each user and add their default SMTP address to the ProxyAddresses field, or use the following script:

Import-Module ActiveDirectory
$domainController = 'dc1.contoso.com'
$searchBase = 'OU=users,DC=contoso,DC=com'
$users = Get-ADUser -SearchBase $searchBase -SearchScope Subtree -Filter { ObjectClass -eq "user" } -Properties ProxyAddresses
ForEach ($user in $users) {
 $newSMTP = 'SMTP:' + $user.userprincipalname
    Write-Host "Adding $newSMTP to" $user.SamAccountName
 Set-ADUser -identity $user.DistinguishedName -Add @{ProxyAddresses = $newSMTP} -server $domaincontroller
}

This script will run through the list of users in a specified OU and add the user’s default SMTP address by using their UserPrincipalName. If your users’ SMTP addresses don’t match your UserPrincipalName, and instead are samaccountname@domain.com, substitute the following for the $newSMTP variable:

$newSMTP = 'SMTP:' + $user.SamAccountName + '@contoso.com'
Advertisements

PowerShell One-Liners: Watching output

Up, enter. Up, enter. Up, enter. Up, enter.

Those two keys are probably being mashed right now somewhere in the world as an engineer waits for a system to do something. Back in my *Nix days, I would have just thrown ‘watch’ in front of whichever command I wanted to keep an eye on and let the shell take care of things for me, but there isn’t quite an analogue in the Windows world.

We can do the same sort of thing, however, by issuing a one line command which repeats until you issue a control-C. For example:

while ($true) {clear;date;netstat -an | findstr LISTENING; sleep 5}

I was using this command today when working with a third party SIP server to make sure the service started listening on the right IP address, and kept refreshing every 5 seconds so I didn’t have to keep tabbing back to a powershell/cmd window to reissue a command.

The basic anatomy of this little script is this:

while ($true)                          # true is always true, so the loop always executes
{                                      # start of the loop
clear;                                 # clear the screen
date;                                  # print the date and time
netstat -an |findstr LISTENING;        # the command you wish to repeat
sleep 5                                # wait for X seconds. in this case 5.
}                                      # end of the loop

The clear and date at the start makes me feel like I’m using the Linux watch command, I guess. Old habits die hard. Note that this is still the same script as the first one, but I’ve just broken it out to separate lines and added comments (the stuff behind the hashes).

Other examples:

# Which services are running?
while ($true) {clear;date;Get-CsWindowsService;sleep 5}
# How are my routing groups looking after I rebooted one of my frontends?
while ($true) {clear;date;Get-CsPoolFabricState -PoolFqdn YourPool.domain.local;sleep 5}
# How many users are logged in before I start patching?
while ($true) {clear;date;(Get-CsUser -OnLyncServer).Count
# How many PSTN calls are active before I take down my mediation server?
while ($true) {clear;date;Get-CsWindowsService -Name RTCMEDSRV | select activitylevel;sleep 5}

We can even take that a step further, by setting a run limit. Let’s say that I wanted to run a command 10 times only. All I need to do is initialize a counter, set the script to only run if the counter is less than or equal to 10, and then get the loop to increment the counter by one each time.

$counter = 1
while ($counter -le 10) {clear;date;$counter;Get-CsWindowsService;sleep 5;$counter = $counter + 1}

How will my Skype for Business call perform?

If you’ve ever been about to jump on an important call or conference, and worried that the network where you are may not be up to the task, then it’s probably a good idea for you to check out the PreCall Diagnostic tool. It’s perfect for when you’re outside your organization, on a public network or on 4G.

Once you start the tool, you’ll need to log in with the details of your Skype for Business or Lync 2013 account. Pressing Start Test will, by default, run a two minute test where it will measure the connection quality between your computer and the server to which you’re connecting. In my case, it’s my edge server as I’m at home.

In the example below, you can see the quality was fine at the beginning of the test, but then I saturated my internet connection by adding a large file to my OneDrive folder (always an excellent test!). Jitter and packet loss spiked, and the overall Mean Opinion Score of the call decreased. This would have resulted in a call which was considered relatively poor.

precall example

Give it a try and see how your network connection compares.