Is that Skype for Business (Lync) Number Free?

Get-CsAdPrincipal is a tragically underused cmdlet. Absent a fully generic Get-CsEndpointObject, it’s the next best thing to Get-ADObject, and is killer when you have no idea what you’re looking for – a User, a Common Area Phone, Conference Dialin Number, Response Group or some crazy custom endpoint used in a Skype-enabled application, especially if all you care about is seeing if a number is available.

There are several scripts for testing each of the Skype for Business object types one by one, and I give some of my favorites at the end of the post; the Get-CsAdPrincipal approach is faster in automation if you’re mostly interested in whether a number is consumed at all, and aren’t concerned with *what* exactly is consuming it.

Get-CsAdPrincipal -LDAPFilter '|(msrtcsip-line=tel:+499112224000*)(msrtcsip-privateline=tel:+499112224000*)'

The LDAP query is checking both the MsRTCSIP-Line and MsRTCSIP-PrivateLine attributes, and there is an asterisk at the end in case the extension was specified separately: tel:+499112224000 and tel:+499112224000;ext=4000 are functionally the same number, but do not look the same to Skype for Business! This is common in places where each line can be directly dialed from outside – that is, much of Europe. I used the attribute names in all lowercase because the mixed-case versions did not work.

If all you wanted was a quick way to check if a number is free or not, you can quit reading now and get back to writing your provisioning script 🙂 If you want to know a bit more about Skype for Business objects, as well as see some really nice stuff for viewing your number pool, stay with me…

Continue reading

ActiveRoles Performance Tip: Use Distinguished Name instead of Canonical Name in OrganizationalUnit Parameters

When making over 100 accounts today for some hard core Skype for Business monitoring, I (re-)discovered that the form of New-QADUser‘s -ParentContainer parameter makes a huge performance difference. I didn’t time it, but noticed that it took about as long to make five accounts using the Canonical Name ( as it did to make the rest of the batch using DN, or Distinguished Name (OU=Purpose,OU=City,OU=State,OU=Region,DC=mandie,DC=net).

This was with Quest ActiveRoles Management Shell for AD 1.7, which goes with ARS 6.9. It was an issue back in the QARMS 1.6/ARS 6.8 days, so hopefully Dell has fixed it for recently-released ARS 7.0. I say “hopefully,” because I can’t find QARMS 1.8(?) anywhere in the ARS 7.0 installation download, much less the Release Notes. Anyhow, it is something to do with how ActiveRoles checks your permissions on the Organizational Unit you are attempting to write to.

You might leave the team responsible for ActiveRoles Server at your company, but ActiveRoles Server never really leaves you…

Hyper-V Switch from Internal to External While VMs Running… No Internets for you!

It’s not every day that you get taught new admin concepts using PowerShell by Jeffrey Snover  himself (the guy who invented PowerShell), but I had the privilege of taking part in the TechDays NL 2015 pre-conference workshop on OneGet PowerShell Package Manager and Desired State Configuration (DSC) that Jeff Wouters (PowerShell MVP) organized, and then led along with Mr. Snover. Both Jeffs patiently answered our (sometimes) silly questions and worked hard to make sure we got as much as possible out of the day.

However, no one was able to save me from myself when I learned that enabling External access for your Internal-only Hyper-V virtual switch while the VMs attached to it are running is apparently a bad idea – at least when your host OS is Windows 10 Technical Preview, Build 10122. This warning didn’t put me off:

Warning schmarning...

… and it appeared to work, but not really: it took out my Internet connection completely. Annoyingly enough, the WiFi claimed that it was connected, along with being bridged. Hyper-V added a nifty new generic Ethernet adapter that was supposed to act as a bridge between the virtual switch and my real WiFi. Note the missing vEthernet (External01) Hyper-V Virtual Ethernet Adapter.

A bridge too far...

Another hint was that Get-NetIPAddress only showed the loopback addresses for both IPv4 and IPv6, and nothing else.

There was no reverse – when I tried switching that virtual switch back to Internal, I got “Error applying Virtual Switch Properties changes”:


Disabling and re-enabling the WiFi connection also did no good; the WiFi was always connected, but traffic was not being passed from applications. Deleting and reinstalling the WiFi adapter was also not an option.

Note the grey text for the

Note the grey text for the “Delete” option.

However, I was able to delete the generic Ethernet adapter.


As soon as that finished, Get-NetIPAddress showed addresses for the WiFi adapter and the virtual switch I hadn’t meddled with. Voila, I had Internet again!

The virtual switch in question was left as a Private Network, and was easily switched back to being Internal. After that, IP addresses (IPv4 and IPv6) showed up for it, too, on Get-NetIPAddress.


The goofy-looking font is a special feature of the 10122 build of Windows 10 for Arial font in various contexts, and can be remedied by some simple method I have completely forgotten.

Wish I’d thought of trying this during the workshop, because package management is kind of hard to work with when you don’t have any way to get to a repository, but here it is for you, dear reader. And for Mr. Snover and Mr. Wouters the next time they teach OneGet… er, PowerShell Package Manager.

Quickly turn SkypeUI on and off without opening Regedit – Skype for Business Preview

The Skype for Business Technical Preview has been pretty great so far, and if I had my choice, I’d use it 100% of the time (get it here). However, I occasionally need to take screenshots for our end users, most of whom have recently been upgraded to Lync 2013 from Office Communicator 2007 R2! Several people have posted the proper registry key to add and change in order to switch UIs (great example here), but frankly, opening Regedit always makes me a tiny bit nervous, even if I am running as a non-admin user. If you are not running as a non-admin user for regular email/Lync/internetting, please think very hard about why!

Here are some little PowerShell functions I’ve written to quickly make this change and restart the Lync/Skype for Business client (can also be downloaded from TechNet Gallery)

# QuickSkypeUISwitch.ps1, Version 1.01
# Amanda Debler,
# now with no-so-new Provider hotness - thanks, Kevin Bird (, for reminding me that providers exist 🙂

# See if the key exists, and if so, what its current value is
function Test-SkypeUIRegKey {
    # old cmd-style registry query
    # reg query "HKCU\Software\Microsoft\Office\Lync" /v EnableSkypeUI
    try {
        get-ItemProperty HKCU:\Software\Microsoft\Office\Lync -Name EnableSkypeUI
    catch [System.Exception] {
    "Registry Key does not exist or cannot be accessed - if Skype for Business UI isn't coming up, try Enable-SkypeUI"
# Lazy assumption that you have Lync set to autostart, plus
# trickery to find, kill and restart your Lync/Skype4B client,
# because I have no idea where you installed it
function Restart-SkypeForBusiness {
    $lyncProcess = Get-Process -Name Lync
    $lyncProcess |  Stop-Process
    Start-Process -FilePath $lyncProcess.Path
# The /f means force - don't care if you have a key there already or not
function Enable-SkypeUI {
    # old but not busted cmd-style registry key insert
    # reg add "HKCU\Software\Microsoft\Office\Lync" /v EnableSkypeUI /t REG_BINARY /d 00000001 /f

    # Note the commas in the Value - Binary registry keys are treated as 4 bytes
    New-ItemProperty HKCU:\Software\Microsoft\Office\Lync -Name EnableSkypeUI -Value 00,00,00,01 -PropertyType Binary -Force
function Disable-SkypeUI {
    # reg add "HKCU\Software\Microsoft\Office\Lync" /v EnableSkypeUI /t REG_BINARY /d 00000000 /f
    New-ItemProperty HKCU:\Software\Microsoft\Office\Lync -Name EnableSkypeUI -Value 00,00,00,00 -PropertyType Binary -Force

Get-CsTopologyFixed Loves Your Simple URLs!

Yes, I know there is no such thing as a tbxml tag. That doesn't mean that there shouldn't be.Remember how I was complaining last week about how Get-CsTopology -AsXml drops the whole SimpleUrlConfiguration node, which makes Topology Builder sad?

Fixed it!

You, too, can enjoy what I do in the evenings on my ridiculous lab machine and get your own readable (though read-only) .tbxml files right from PowerShell:

Get-CsTopologyFixed (hosted on TechNet Gallery)

It works for View-Only Administrators (CsViewOnlyAdministrator), as well as full CsAdministrator (or equivalent), so your telephone gal or Exchange guy can grab a copy whenever they need to check something or a consultant wants a copy so that they understand what’s going on with Lync in your environment. I have not tested it with an account that only has, for example, CsUserAdministrator or CsServerAdministrator.

For people who are not (yet) hard-core PowerShellers: this script is a function, not a standalone script. Running it “dot-sourced” will add the Get-CsTopologyFixed cmdlet to your current PowerShell session, or you can add the function to your Lync Server connection script. You need to either be on a computer with Lync Management Shell (part of the Lync management tools on the Lync Server installer image) or implicitly remoted to one that has it in order to access the native Lync Server cmdlets.

Here is the function to take the output of Get-CsSimpleUrlConfiguration and put it into an XML node, which my full script then drops into the rest of the Topology XML:

    function Convert-CsSimpleUrlConfigurationToXMLText { 
        $GetCsSimpleUrlConfiguration = Get-CsSimpleUrlConfiguration 
        $SimpleUrlConfigurationOut = "" 
        $simpleUrlConfigurationOut += '<SimpleUrlConfiguration xmlns="urn:schema:Microsoft.Rtc.Management.Settings.SimpleUrl.2008" UseBackendDatabase="false">' 
        foreach ($simpleUrl in $GetCsSimpleUrlConfiguration.SimpleUrl) { 
            $SimpleUrlConfigurationOut += "<SimpleUrl Component=`"$($simpleUrl.Component)`" Domain=`"$($simpleUrl.Domain)`" ActiveUrl=`"$($simpleUrl.ActiveUrl)`">" 
            foreach ($simpleUrlEntry in $simpleUrl.SimpleUrlEntry) { 
                $SimpleUrlConfigurationOut += "<SimpleUrlEntry Url=`"$($simpleUrlEntry.Url)`" />" 
            $SimpleUrlConfigurationOut += "</SimpleUrl>" 
        $SimpleUrlConfigurationOut += '</SimpleUrlConfiguration>' 

I have no idea if it works (or is even necessary) on Lync Server 2010. If Microsoft will let me have a preview copy, I’d be willing to find out if it works (or is even necessary) on Skype for Business 😉

If you find something wrong with my script, or come up with an improvement, let me know!

PowerShell Heart Logo

PowerShell logo in a heart

I love PowerShell, and so should you!

The #PowerShellChicks group was initiated by the foremost lady of PowerShell, June Blender:

I think we need a logo! A PowerShell symbol hatching from an egg would have been awesome, but my graphic design skills are pretty much limited to PowerPoint. To celebrate having my session on Lync admin basics selected for the 2015 PowerShell Summit Europe, here’s a little something I knocked together. If someone wants to do the curved gradient and motion lines that are on the real logo (and perhaps improve the overall proportions), knock yourself out and let me know about it!



Comparing Lync Policies – or How to Flip Just About Any Array of Hashtables in PowerShell

If you are reading this blog and can read German, I don’t need to tell you about, former Exchange and now Lync MVP Frank Carius’ online (but not very alphabetical) encyclopedia of Exchange and Lync – it probably gets more page views in a day than this blog ever has. Even if you cannot read German, you have still probably run into it when searching for Exchange or Lync topics and then seriously wished you could read German – machine translation only goes so far.

Anyhow, one of the most helpful things he’s put out there and that I use all the time is a Swap-Table script. I wasn’t able to turn it up with “flip table in PowerShell” or “pivot PowerShell table” or any of several variations, so this is a little attempt to make that wonderful file findable for the English-speaking world. Scroll to the bottom and look for the “Code” section. You can make it a function in your PowerShell profile by putting the contents of that text file inside the curly braces {} of the following (code not posted here because plagiarism is evil):

function Swap-Table {
# contents of swap-table.1.0.ps1 go here


It has been particularly useful for comparing ClientPolicies and ConferencingPolicies in Lync, as ClientPolicy has over 70 attributes! Once you have the function in your session and you’re connected to Lync Management Shell, it works like this:

Get-CsClientPolicy | Swap-Table | Out-GridView