Here are some examples of using UcmPsTools in your own scripts to automate administrative tasks in Microsoft Teams
Moving users from OnPrem to O365
Script to Licence a user for Teams and Telstra calling, Enable the relevant Office365 Service Plans (apps), Clear the local attributes and move the user.
Uses functions from UcmPsTools to licence users and enable services.
Copy [hashtable]$User = @{}
$User.UPN = "$username@contoso.com"
#Assign Licences (UcmPsTools Cmdlets)
#Enterprise Voice
#Grant-UcmOffice365UserLicence -upn $user.upn -LicenceType 'MCOEV' -Country 'AU'
#Telstra Calling
#Grant-UcmOffice365UserLicence -upn $user.upn -LicenceType 'MCOPSTNEAU2' -Country 'AU'
#Enable O365 Apps (UcmPsTools Cmdlets)
#Skype for Business Online
#Enable-UcmO365Service -upn $user.upn -ServiceName MCOSTANDARD
#Teams
#Enable-UcmO365Service -upn $user.upn -ServiceName TEAMS1
#Telstra Calling
#Enable-UcmO365Service -upn $user.upn -ServiceName MCOPSTNEAU
#Clear Local attributes
SkypeForBusiness\Set-CsUser -Identity $user.upn -LineUri $null -EnterpriseVoiceEnabled $False
#Move the user to O365
Move-CsUser -Identity $user.upn -Target sipfed.online.lync.com -MoveToTeams -HostedMigrationOverrideUrl $url -Confirm:$false -ProxyPool SfbFe1.contoso.com -BypassAudioConferencingCheck -UseOAuth
Grant-CsTeamsUpgradePolicy -PolicyName UpgradeToTeams -Identity $user.upn
Grant-CsTenantDialPlan -Identity $user.upn -PolicyName "VICTasDialplan-Unrestricted"
Remember: This is just an example, you should customize your scripts to your needs
Creating Number Forwards using Auto Attendants
Tip: New-CsFixedNumberDiversion does this with a lot more safety checks
Script to create and licence an Office365 AutoAttendant to forward a call to an external number.
Uses UcmPsTools cmdlets to check for an existing connection, and add licences.
Copy [string]$OriginalNumber="6170105050"
[string]$TargetNumber="61370105000"
[string]$AccountPrefix="PSTN_FWD_",
[string]$Domain="Contoso.com"
[string]$LicenceType="MCOPSTNEAU2"
[string]$Country="AU"
[string]$AADisplayName="Example AutoAttendant"
#Check for connection and reconnect (UcmPsTools Cmdlet)
$Test = (Test-SFBOConnection -reconnect)
If ($Test.Status -eq "Error")
{
Throw "No SFBO Connection"
}
#check for and create a resource account
$UPN = ($AccountPrefix + $OriginalNumber + "@" + $domain)
$AAAccount = $null
$AAAccount = (Get-CsOnlineApplicationInstance | Where-Object {$_.UserPrincipalName -eq $UPN})
if ($AAAccount .UserPrincipalName -eq $UPN)
{
Write-UcmLog -Message "Resource Account already exists, Skipping" -Severity 3 -Component $function
}
Else
{
#Create the required resource account (UcmPsTools Cmdlet)
New-UcmTeamsResourceAccount -UPN $UPN -DisplayName $AADisplayName -ResourceType AutoAttendant
#Licence the account for Voice and PSTN (UcmPsTools Cmdlets)
$Licence1 = (Grant-UcmOffice365UserLicence -licencetype PHONESYSTEM_VIRTUALUSER -country $country -upn $upn)
$Licence2 = (Grant-UcmOffice365UserLicence -licencetype $licencetype -country $country -upn $upn)
#Check for AutoAttendant
$o=$null
$o=(Get-CsAutoAttendant -NameFilter $AADisplayName)
If ($o -eq $BeNullOrEmpty)
{
#Create AutoAttendant
$CallForwardEntity = New-CsAutoAttendantCallableEntity -Identity "tel:+$TargetNumber" -Type ExternalPSTN
$DiversionMenuOption = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -DtmfResponse Automatic -CallTarget $CallForwardEntity
$DiversionMenu = New-CsAutoAttendantMenu -Name "Fixed Diversion" -MenuOptions @($DiversionMenuOption)
$DiversionCallFlow = New-CsAutoAttendantCallFlow -Name "Fixed Diversion" -Menu $DiversionMenu
$o=New-CsAutoAttendant -Name $AADisplayName -DefaultCallFlow $DiversionCallFlow -CallHandlingAssociations @($afterHoursCallHandlingAssociation) -Language "en-AU" -TimeZoneId "AUS Eastern Standard Time"
$applicationInstanceId = (Get-CsOnlineUser $UPN).ObjectId
New-CsOnlineApplicationInstanceAssociation -Identities @($applicationInstanceId) -ConfigurationId $O.identity -ConfigurationType AutoAttendant
}
#Assign the phone number to the resource account
Set-CsOnlineVoiceApplicationInstance -Identity $UPN -TelephoneNumber $telephoneNumber -verbose