UcmPsTools Documentation
  • Welcome! - UcmPsTools
  • Using UcmPsTools
    • QuickStart
    • About UcmPSTools
    • Using UcmPsTools in your Automation
    • Cmdlet Reference
      • Accounts and Voice Apps
        • New-UcmOffice365User -todo
        • New-UcmTeamsResourceAccount - todo
      • Auditing and Planning
        • Measure-UcmOnPremNumberRange
      • Call Management
        • New-UcmCsFixedNumberDiversion
      • Connections and Modules
      • Licences and Service Plans
      • Reporting and Logging
        • Complete-UcmReport
        • Export-UcmCSVReport
        • Export-UcmHTMLReport
        • Initialize-UcmReport
        • New-UcmReportItem
        • New-UcmReportStep
        • Search-UcmCsOnPremNumberRange
        • Write-UcmLog
    • Example Scripts
  • UcmPsTools In Depth
    • More about UcmPsTools
    • Security In UcmPsTools
    • UcmPsTools Cmdlet Status Reporting
  • Contributing to UcmPsTools
    • New Function Rules
    • Pull Process
Powered by GitBook
On this page
  • Moving users from OnPrem to O365
  • Creating Number Forwards using Auto Attendants
  1. Using UcmPsTools

Example Scripts

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.

[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.

[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
PreviousWrite-UcmLogNextMore about UcmPsTools

Last updated 2 years ago