Simple Surface Hub Account Configuration

I was looking through the documentation for setting up an account for a Surface Hub. It's a wonderful set of documentation, but it's also very long! Most of this was just more detailed than I needed, but I wanted a very simple, easy-to-follow script for building this in Office 365. I don't like to do anything by hand, since I may need to do another in the future. I like consistency. This isn't going to be ideal if you need to deploy scores of them, but this works well for deploying a few.

The first thing you'll need is to install the modules that are used for this script:

Got that working? Good. On to the script and what it does.

I really just stepped through the Surface Hub installation steps and set up sequential commands for each section. You would need to run this several times, 10 minutes or so apart, to give time to create the mailbox and for replication to finish. You know it's working when the errors stop. The Get-CsMeetingRoom at the end is what needs to succeed for this to be completed. If that works, you should be good.

All this code comes with the normal disclaimers, of course. Try this in a lab, if at all possible. You’re on your own here – there’s no warranty on this. If you use it, please leave a comment. And remember, this is only for Office 365. On-premises systems would be done differently.

(Note that I updated this script on 3/31/2017 to take care of making the password not expire. That's very important!)

 # New-SurfaceHubAccount.ps1 - grb - 03/31/2017 - Adds and configures a new Surface Hub account.

# Configuration variables. You need to replace these with whatever makes sense
# for your environment - especially the password!
$SurfaceHubDisplayname = 'Surface Hub 01'
$SurfaceHubAlias = 'SurfaceHub01'
$SurfaceHubPassword = 'Super-Secret1Password!'
$SurfaceHubMobilePolicy = "Surface Hubs"
$AdminAcccount = 'admin@contoso.com'


# Login to all necessary shells
$MSOLCred = Get-Credential -credential $AdminAcccount
#Azure
Import-Module MSOnline
Connect-MsolService -Credential $MSOLCred
#Exchange Online
$ExSession = New-PSSession -ConfigurationName Microsoft.Exchange 
  -ConnectionUri https://outlook.office365.com/powershell-liveid/ `
   -Credential $MSOLCred -Authentication Basic –AllowRedirection
Import-PSSession $ExSession –AllowClobber -Verbose
#Skype for Business Online
Import-Module LyncOnlineConnector
$lyncsession = New-CsOnlineSession –credential $MSOLCred
Import-PSSession $lyncsession –AllowClobber -Verbose


# Additional calculated variables
$SurfaceHubLicense = (Get-MsolAccountSku | ? {$_.AccountSkuID -like "*ENTERPRISEPREMIUM"}).AccountSkuID
$MSOLAccountSKU = Get-MsolAccountSku
$TenantId = $MSOLAccountSKU[0].AccountObjectId.Guid 
$TenantName = ($MSOLAccountSKU[0].AccountName)
$TenantDomain = $TenantName+'.onmicrosoft.com'
$SurfaceHubAccount = $SurfaceHubAlias+'@'+$TenantDomain


# Create mailbox and configure
New-Mailbox -MicrosoftOnlineServicesID $SurfaceHubAccount -Alias $SurfaceHubAlias -Name $SurfaceHubDisplayname 
  -Room -EnableRoomMailboxAccount $true -RoomMailboxPassword (ConvertTo-SecureString  `
   -String $SurfaceHubPassword -AsPlainText -Force) -ErrorAction SilentlyContinue

New-MobileDeviceMailboxPolicy -Name $SurfaceHubMobilePolicy -PasswordEnabled $false -ErrorAction silentlycontinue
Set-CASMailbox -Identity $SurfaceHubAccount -ActiveSyncMailboxPolicy $SurfaceHubMobilePolicy

Set-CalendarProcessing -Identity $SurfaceHubAccount -AutomateProcessing AutoAccept -AddOrganizerToSubject $false 
    –AllowConflicts $false –DeleteComments $false -DeleteSubject $false -RemovePrivateProperty $false

Set-CalendarProcessing -Identity $SurfaceHubAccount -AddAdditionalResponse $true `
 -AdditionalResponse "This room is equipped with a Surface Hub"

Set-Msoluser -UserPrincipalName $SurfaceHubAccount -UsageLocation US
Set-MsolUser -UserPrincipalName $SurfaceHubAccount -PasswordNeverExpires $true

# Apply Office 365 License
Set-MsolUserLicense -UserPrincipalName $SurfaceHubAccount -AddLicenses $SurfaceHubLicense `
   -ErrorAction SilentlyContinue

Get-CASMailbox $SurfaceHubAccount | fl Identity,ActiveSyncMailboxPolicy
Get-MsolUser -UserPrincipalName $SurfaceHubAccount | fl DisplayName,UsageLocation

# Skype for Business account and configuration.
$RegistrarPool = (Get-CsOnlineUser -Identity $SurfaceHubAccount).RegistrarPool

Enable-CsMeetingRoom -Identity $SurfaceHubAccount -RegistrarPool $RegistrarPool -SipAddressType EmailAddress
Get-CsMeetingRoom -identity $SurfaceHubAccount | fl DisplayName,IsValid,SipAddress

# Log out of all sessions
Get-PSSession | Remove-PSSession

echo "end of script"