Friday, August 30, 2013

Enable Specific Office 365 Licenses using PowerShell

I found myself recently with the need to assign specific licenses within the Enterprise Pack to Office 365 users from PowerShell. This is fairly trivial from the Portal web interface, but when you assign a license using the following command it assigns ALL the licenses in the Enterprise Pack:

Set-MsolUserLicense -UserPrincipalName "" -AddLicenses <Office365Sku>

This is fine if that is what you want, but my customer wanted to only assign the Lync Online license

So I set about trying to figure out how to do it. I found the pieces to the answer in several different places... so I figured I'd put it all together in one blog post.

First off... you need to get your account SKU

PS C:\scripts> Get-MsolAccountSku
AccountSkuId                    ActiveUnits     WarningUnits    ConsumedUnits
------------                    -----------     ------------    ----
somecustomer:ENTERPRISEPACK      1000            0               127

If you have more than one... pick the appropriate one and place that in the variable $office365sku below.

Okay... now pay attention... the next variable is the licenses we want to DISABLE. Yes that is right... we enable all the licenses first, and then we disable what we don't want. To see the different options enter this command:

PS C:\scripts> Get-MsolAccountSku | Where-Object {$_.SkuPartNumber -eq 'ENTERPRISEPACK'} | ForEach-Object {$_.ServiceStatus}

ServicePlan                             ProvisioningStatus
-----------                             ------------------
RMS_S_ENTERPRISE                        Success
OFFICESUBSCRIPTION                      Success
MCOSTANDARD                             Success
SHAREPOINTWAC                           Success
SHAREPOINTENTERPRISE                    Success
EXCHANGE_S_ENTERPRISE                   Success

The order above matches the order in the Portal web interface.

Just a side note, the "Office Web Apps" is not needed for Lync Online. The Office Web Apps license has to do with SharePoint Office Web Apps, not the Office Web Apps used with Lync Online.

So... in the $options variable below you need to modify the licenses you want to disable. Below is an example of the licenses disabled to only leave Lync Online enabled.

That's it... enjoy.

# Script to Enable Specific Office 365 Licenses using PowerShell
# Created By Jonathan McKinney (
# Time2Market 2013

$msoluser = "lynctest at"
$office365sku = "somecustomer:ENTERPRISEPACK"

$transcriptname = “Office365License” + `
    (Get-Date -format s).Replace(“:”,”-”) +”.txt”
Start-Transcript $transcriptname

  Write-Host  `r
  Write-Host  `r`n 'Enable licenses for ' $msoluser `r`n
  Set-MsolUser -UserPrincipalName $msoluser -UsageLocation US
  Set-MsolUserLicense -UserPrincipalName $msoluser -AddLicenses $office365sku
  Set-MsolUserLicense -UserPrincipalName $msoluser -LicenseOptions $options
  Write-Host  `r


Friday, August 16, 2013

Script to Automate the Connection to Lync Online

So you just saw that new Microsoft Download for Windows PowerShell Module for Lync Online... got you pretty excited right?!

At least until you finished the install and didn't read the documentation :-) were left wondering how to use it. Well don't fret any longer here is a handy script I've been using to connect. If you are running on a Windows 7 or other workstation you'll need to set your PowerShell Execution Policy.

# Script to Automate connection to Lync Online
# Created By Jonathan McKinney (
# Time2Market 2013

Import-Module LyncOnlineConnector

$cred = Get-Credential
$CsSession = New-CsOnlineSession -Credential $cred

Import-PSSession $CsSession

Write-Host  `r`n 'To get a list of available Lync Online commands Enter Get-Command -Module <ScriptNameAbove>' `r`n -ForegroundColor Yellow
Write-Host  `r`n 'To remove Remote Powershell Session Enter Get-PsSession and then Remove-PsSession -Id <ID number of session listed>' `r`n -ForegroundColor Yellow

Pretty neat, huh?

So what can you do once you have access? Mostly look around and wish you could change stuff.

Couple of useful things you can do... Set ACP info and Grant policies to users.

Here is how you set ACP info do it if your customer uses Intercall

Set-CsUserAcp -Identity "lynctest at" -Name "InterCall" -Domain "" -TollNumber "4255551234" -TollFreeNumbers "8665551234" -ParticipantPasscode "4255552345" -Url

Here is an example of how you can Grant no recording through a conferencing policy

Grant-CsConferencingPolicy "lynctest at" -PolicyName BposSAllModalityNoRec 

So... Ummm... how do you get a list of all the Policies available (since we can't change or add them)


Wow... big list eh?

or if you just want to see the names of the policies

Get-CsConferencingPolicy | select identity

Here is a list of commands that I have access to...

CommandType     Name
-----------     ----
Function        Copy-CsVoicePolicy
Function        Disable-CsMeetingRoom
Function        Enable-CsMeetingRoom
Function        Get-CsAudioConferencingProvider
Function        Get-CsClientPolicy
Function        Get-CsConferencingPolicy
Function        Get-CsDialPlan
Function        Get-CsExternalAccessPolicy
Function        Get-CsExUmContact
Function        Get-CsHostedVoicemailPolicy
Function        Get-CsImFilterConfiguration
Function        Get-CsMeetingConfiguration
Function        Get-CsMeetingRoom
Function        Get-CsOnlineUser
Function        Get-CsPresencePolicy
Function        Get-CsPrivacyConfiguration
Function        Get-CsPushNotificationConfiguration
Function        Get-CsTenant
Function        Get-CsTenantFederationConfiguration
Function        Get-CsTenantHybridConfiguration
Function        Get-CsTenantLicensingConfiguration
Function        Get-CsTenantPublicProvider
Function        Get-CsUserAcp
Function        Get-CsVoicePolicy
Function        Grant-CsClientPolicy
Function        Grant-CsConferencingPolicy
Function        Grant-CsDialPlan
Function        Grant-CsExternalAccessPolicy
Function        Grant-CsHostedVoicemailPolicy
Function        Grant-CsVoicePolicy
Function        New-CsEdgeAllowAllKnownDomains
Function        New-CsEdgeAllowList
Function        New-CsEdgeDomainPattern
Function        New-CsExUmContact
Function        Remove-CsExUmContact
Function        Remove-CsUserAcp
Function        Remove-CsVoicePolicy
Function        Set-CsExUmContact
Function        Set-CsMeetingConfiguration
Function        Set-CsMeetingRoom
Function        Set-CsPrivacyConfiguration
Function        Set-CsPushNotificationConfiguration
Function        Set-CsTenantFederationConfiguration
Function        Set-CsTenantHybridConfiguration
Function        Set-CsTenantPublicProvider
Function        Set-CsUser
Function        Set-CsUserAcp

Welcome to Lync Online PowerShell...