Share via


PowerShell gebruiken om Diensten te verbinden met Blue Yonder-personeelsbeheer

Overzicht

Gebruik de Microsoft Teams Diensten-connector voor Blue Yonder om de Diensten-app in Microsoft Teams te integreren met Blue Yonder-personeelsbeheer (Blue Yonder WFM). Uw frontlijnmedewerkers kunnen hun planningen in Blue Yonder naadloos bekijken en beheren WFM vanuit Shifts.

In dit artikel wordt uitgelegd hoe je PowerShell gebruikt om de connector in te stellen en te configureren om Diensten te integreren met Blue Yonder WFM.

Als je de verbinding wilt instellen, voer je een PowerShell-script uit. Het script configureert de connector, past synchronisatie-instellingen toe, maakt verbinding en wijst Blue Yonder WFM-exemplaren toe aan teams. De synchronisatie-instellingen bepalen de functies die zijn ingeschakeld in Diensten en de roosterinformatie die tussen Blue Yonder WFM en Diensten wordt gesynchroniseerd. Toewijzingen definiëren de synchronisatierelatie tussen je Blue Yonder WFM-exemplaren en -teams in Teams. Je kunt aan bestaande teams en nieuwe teams toewijzen.

We bieden twee scripts. Je kunt beide scripts gebruiken, afhankelijk van of je aan bestaande teams toewijst of nieuwe teams wilt maken om aan toe te wijzen.

Je kunt meerdere verbindingen instellen, elk met verschillende synchronisatie-instellingen. Als je organisatie bijvoorbeeld meerdere locaties met verschillende planningsvereisten heeft, maak je voor elke locatie een afzonderlijke verbinding met unieke synchronisatie-instellingen. Houd er rekening mee dat een Blue Yonder WFM-exemplaar op elk moment slechts aan één team kan zijn toegewezen. Als een exemplaar al is toegewezen aan een team, kan het niet worden toegewezen aan een ander team.

Met Blue Yonder WFM als recordsysteem kunnen uw frontlijnmedewerkers hun planningen en beschikbaarheid in Shifts op hun apparaten efficiënt beheren. Frontlijnmanagers kunnen Blue Yonder WFM blijven gebruiken om roosters in te stellen.

Opmerking

Je kunt ook de Wizard diensten-connector in het Microsoft 365-beheercentrum gebruiken om Diensten te verbinden met Blue Yonder WFM.

Voordat u begint

Vereisten

Voordat u aan de slag gaat, moet u aan alle volgende vereisten voldoen:

  • U hebt Blue Yonder WFM versie 2020.3, 2021.1 of 2021.2.

    Opmerking

    Als u Blue Yonder WFM 2020.3 of 2021.1 hebt, past u de patch 2020.3.0.4 of 2021.1.0.3 toe. Met deze patch wordt een probleem opgelost waarbij gebruikers voortdurend een foutbericht krijgen in Shifts. Er wordt ook een probleem opgelost dat voorkomt dat gebruikers hun beschikbaarheid in Shifts bijwerken.

  • U kent uw Blue Yonder WFM naam, wachtwoord en service-URL's:

    • URL voor federatieve verificatie
    • URL voor cookieverificatie
    • URL voor Employee Self-Service
    • URL voor retail-web-API
    • URL voor sitebeheerder-API
    • URL voor beheer-API

    Als u niet al deze informatie hebt, neemt u contact op met de ondersteuning van Blue Yonder. Een Blue Yonder-account wordt gemaakt op het niveau van de hoofdonderneming door een Blue Yonder enterprise-beheerder. Het moet API-toegang, clienttoegang Beheer, Store Manager en werkroltoegang hebben. Het account en wachtwoord zijn nodig om een verbinding te maken.

  • Federatieve SSO-verificatie is ingeschakeld in uw Blue Yonder WFM-omgeving. Neem contact op met de ondersteuning van Blue Yonder om te controleren of federatieve eenmalige aanmelding is ingeschakeld. Ze hebben de volgende gegevens nodig:

    • federatedSSOValidationService: https://wfmconnector.teams.microsoft.com/api/v1/fedauth/{tenantId}/6A51B888-FF44-4FEA-82E1-839401E9CD74/authorize waar {tenantId} is uw tenantId
    • proxyHeader: X-MS-AuthToken
  • U hebt ten minste één team ingesteld in Teams.

  • U hebt een algemeen account, wat we het Microsoft 365-systeemaccount noemen, als teameigenaar toegevoegd aan alle teams die u wilt toewijzen.

    Maak dit account in de Microsoft 365-beheercentrum en wijs er een Microsoft 365-licentie aan toe. Voeg vervolgens het account als teameigenaar toe aan alle teams die u wilt toewijzen. De Shifts-connector gebruikt dit account bij het synchroniseren van Shifts-wijzigingen van Blue Yonder WFM. We raden u aan om specifiek voor dit doel een account te maken en niet uw persoonlijke gebruikersaccount te gebruiken.

Beheerdersrol voor het beheren van de connector met behulp van PowerShell

U moet een globale beheerder van Microsoft 365 of een shifts-connectorbeheerder zijn om de stappen in dit artikel uit te voeren.

De beheerdersrol shifts-connector is een aangepaste rol die u maakt in Microsoft Entra id en toewijst aan een gebruiker. De naam van de rol moet "Shifts-connectorbeheerder" zijn. De rol hoeft geen specifieke machtigingen te hebben, hoewel er ten minste één machtiging moet worden ingesteld wanneer u deze maakt. De service is afhankelijk van de aanwezigheid van de rol van de gebruiker en niet van de bijbehorende machtigingen.

Zie Een aangepaste rol maken en toewijzen in Microsoft Entra id en Microsoft Entra rollen toewijzen aan gebruikers voor meer informatie. Houd er rekening mee dat het tot 24 uur kan duren voordat de rol is gemaakt en toegepast op een gebruiker.

Uw omgeving instellen

  1. Installeer PowerShell-versie 7 of hoger. Raadpleeg PowerShell op Windows installeren voor stapsgewijze instructies.

  2. Voer Powershell uit in de administrator-modus.

  3. Installeer de Microsoft Graph PowerShell-module.

    Install-Module Microsoft.Graph
    Import-Module Microsoft.Graph
    

    Controleer of het versie 1.6.1 of hoger is.

    Get-InstalledModule Microsoft.Graph 
    
  4. Installeer de PowerShell-module Teams Preview.

    Install-Module -Name MicrosoftTeams -AllowPrerelease -Force
    Import-Module MicrosoftTeams 
    

    Controleer of het ten minste versie 4.7.0 is en de Shifts-connector-cmdlets bevat.

    Get-Command -Module MicrosoftTeams -Name *teamsshiftsconnection* 
    
  5. Stel PowerShell in om af te sluiten als er een fout optreedt bij het uitvoeren van het script.

    $ErrorActionPreference = "Stop" 
    
  6. Schakel scripts in om uit te voeren in Windows.

    Set-ExecutionPolicy bypass 
    

Verbinding maken met Teams

Voer het volgende uit om verbinding te maken met Teams.

Connect-MicrosoftTeams

Wanneer je hierom wordt gevraagd, meld je aan met je beheerdersreferenties. Je bent nu klaar om de scripts in dit artikel en Diensten-connector-cmdlets uit te voeren.

Identificeer de teams waaraan je wilt toewijzen

Opmerking

Voltooi deze stap als je Blue Yonder WFM-exemplaren aan bestaande teams wilt toewijzen. Als je nieuwe teams maakt om aan toe te wijzen, kun je deze stap overslaan.

Ga in de Azure-portal naar de pagina Alle groepen om een lijst met team-id's van teams in je organisatie op te halen.

Noteer de Team-id's van de teams waaraan je wilt toewijzen. Het script vraagt je om deze informatie in te voeren.

Opmerking

Als een of meer teams een bestaand rooster hebben, worden de roosters door het script uit deze teams verwijderd. Anders krijg je dubbele diensten.

Voer het script uit

Voer een van de volgende scripts uit, afhankelijk van of u een nieuw team maakt of aan een bestaand team toegeeft:

  • Als u een verbinding wilt instellen, een nieuw team wilt maken in Teams en een Blue Yonder-WFM-exemplaar wilt toewijzen aan het nieuwe team, voert u het nieuwe teamsscript uit.
  • Als u een verbinding wilt instellen en Blue Yonder WFM-exemplaren wilt toewijzen aan bestaande teams in Teams, voert u het bestaande teams-script uit.

Volg de instructies op het scherm wanneer u het script uitvoert. Het script voltooit de volgende acties:

  1. Test en controleer de verbinding met Blue Yonder WFM met behulp van de referenties en service-URL's van het Blue Yonder-WFM-serviceaccount.

  2. Synchronisatie-instellingen toepassen. Deze instellingen omvatten de synchronisatiefrequentie (in minuten) en de planningsgegevens die zijn gesynchroniseerd tussen Blue Yonder WFM en Shifts. U kunt planningsgegevens inschakelen die zijn gedefinieerd door deze scenario's: Shift, SwapRequestUserShiftPreferences, OpenShift, OpenShiftRequest, TimeOff, , TimeOffRequest.

    Raadpleeg New-CsTeamsShiftsConnectionInstance voor meer informatie. Als je de lijst met ondersteunde synchronisatieopties voor elke parameter wilt bekijken, voer je Get-CsTeamsShiftsConnectionConnector uit.

    Opmerking

    Met het script wordt synchronisatie ingeschakeld voor elke ondersteunde synchronisatieoptie. Als je de synchronisatie-instellingen wilt wijzigen, kun je dit doen nadat de verbinding is ingesteld. Raadpleeg voor meer informatie PowerShell gebruiken om je Diensten-verbinding met Blue Yonder Workforce Management te beheren.

  3. Wijs Blue Yonder WFM-exemplaren toe aan uw teams in Teams.

    • Als u ervoor kiest om het nieuwe teamsscript uit te voeren om nieuwe teams te maken, worden toewijzingen gebaseerd op de nieuwe teams die u maakt.
    • Als u ervoor kiest om het bestaande teamsscript uit te voeren om bestaande teams toe te wijzen, zijn toewijzingen gebaseerd op blue Yonder-exemplaar-id's en TeamIds die u invoert. Als een team een bestaande planning heeft, verwijdert het script alle planningsgegevens.

Nadat u het script hebt uitgevoerd, wordt in het bericht Geslaagd bevestigd of de verbinding is ingesteld.

Uw verbinding beheren

Nadat een verbinding is ingesteld, kunt u deze beheren en wijzigen in de Microsoft 365-beheercentrum of met behulp van PowerShell.

De Microsoft 365-beheercentrum gebruiken

Op de pagina Connectorbeheer vindt u elke verbinding die u hebt ingesteld, samen met informatie zoals de status en details van het synchronisatie-interval. U kunt ook toegang krijgen tot de wizard om wijzigingen aan te brengen in een van uw verbindingen. U kunt bijvoorbeeld synchronisatie-instellingen en teamtoewijzingen bijwerken.

Zie Use the Microsoft 365-beheercentrum to manage your Shifts connection to Blue Yonder Workforce Management (De Microsoft 365-beheercentrum gebruiken om uw Shifts-verbinding met Blue Yonder te beheren) voor meer informatie.

PowerShell gebruiken

U kunt PowerShell gebruiken om een foutenrapport weer te geven, verbindingsinstellingen te wijzigen, synchronisatie uit te schakelen en meer. Voor stapsgewijze instructies raadpleeg PowerShell gebruiken om uw Diensten-verbinding met Blue Yonder Workforce Management te beheren.

Scripts

Een verbinding instellen en een nieuw team maken

#Map WFM sites to teams script
Write-Output "Map WFM sites to teams"
Start-Sleep 1

#Ensure Teams module is at least version x
Write-Output "Checking Teams module version"
try {
	Get-InstalledModule -Name "MicrosoftTeams" -MinimumVersion 5.2.0
} catch {
	throw
}

#Connect to MS Graph
Connect-MgGraph -Scopes "User.Read.All","Group.ReadWrite.All"

#List connector types available (comment out if not implemented for preview)
Write-Output "Listing connector types available"
$BlueYonderId = "6A51B888-FF44-4FEA-82E1-839401E9CD74"
$connectors = Get-CsTeamsShiftsConnectionConnector
Write-Output $connectors

#Prompt for entering of WFM username and password
$WfmUserName = Read-Host -Prompt 'Input your Blue Yonder account username'
$WfmPwd = Read-Host -Prompt 'Input your Blue Yonder account password' -AsSecureString
$plainPwd =[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($WfmPwd))

#Test connection settings
Write-Output "Testing connection settings"
$ConnectionName = Read-Host -Prompt 'Input connection name'
$adminApiUrl = Read-Host -Prompt 'Input admin api url'
$cookieAuthUrl = Read-Host -Prompt 'Input cookie authorization url'
$essApiUrl = Read-Host -Prompt 'Input ess api url'
$federatedAuthUrl = Read-Host -Prompt 'Input federated authorization url'
$retailWebApiUrl = Read-Host -Prompt 'Input retail web api url'
$siteManagerUrl = Read-Host -Prompt 'Input site manager url'

$testResult = Test-CsTeamsShiftsConnectionValidate `
	-Name $ConnectionName `
	-ConnectorId $BlueYonderId `
    -ConnectorSpecificSettings (New-Object Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Models.ConnectorSpecificBlueYonderSettingsRequest `
        -Property @{
            AdminApiUrl = $adminApiUrl
            SiteManagerUrl = $siteManagerUrl
            EssApiUrl = $essApiUrl
            RetailWebApiUrl = $retailWebApiUrl
            CookieAuthUrl = $cookieAuthUrl
            FederatedAuthUrl = $federatedAuthUrl
            LoginUserName = $WfmUserName
            LoginPwd = $plainPwd
        })
if ($NULL -ne $testResult.Code) {
	Write-Output $testResult
	throw "Validation failed, conflict found"
}
Write-Output "Test complete, no conflicts found"

#Create a connection
Write-Output "Creating a connection"
$ConnectionResponse = New-CsTeamsShiftsConnection `
    -Name $ConnectionName `
    -ConnectorId $BlueYonderId `
    -ConnectorSpecificSettings (New-Object Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Models.ConnectorSpecificBlueYonderSettingsRequest `
		-Property @{
			AdminApiUrl = $adminApiUrl
			SiteManagerUrl = $siteManagerUrl
			EssApiUrl = $essApiUrl
			RetailWebApiUrl = $retailWebApiUrl
			CookieAuthUrl = $cookieAuthUrl
			FederatedAuthUrl = $federatedAuthUrl
			LoginUserName = $WfmUserName
			LoginPwd = $plainPwd
		})

$ConnectionId = $ConnectionResponse.Id
if ($null -ne $ConnectionId){
	Write-Output "Successfully created connection"
} else {
	throw "Connection creation failed"
}

#Create a connection instance
Write-Output "Creating a connection instance"
$designatedActorName = Read-Host -Prompt "Input Microsoft 365 System Account (person@contoso.com)"
$designator = Get-MgUser -UserId $designatedActorName
$teamsUserId = $designator.Id
$syncFreq = Read-Host -Prompt "Input sync frequency in minutes"
$InstanceName = Read-Host -Prompt "Input connection instance name"

#Read sync scenarios for connection instance
function GetSyncScenarioSetting {
	param (
		$SettingName
	)
	$TwoWay = New-Object System.Management.Automation.Host.ChoiceDescription '&TwoWay', 'TwoWay'
	$Disabled = New-Object System.Management.Automation.Host.ChoiceDescription '&Disabled', 'Disabled'
	$FromWfmToShifts = New-Object System.Management.Automation.Host.ChoiceDescription '&FromWfmToShifts', 'FromWfmToShifts'
	$options = [System.Management.Automation.Host.ChoiceDescription[]]($TwoWay, $Disabled, $FromWfmToShifts)
	$result = $host.ui.PromptForChoice("Set sync scenario for $SettingName", "", $options, 0)

	switch ($result)
	{
		0 { return "TwoWay" }
		1 { return "Disabled" }
		2 { return "FromWfmToShifts" }
	}
}
$SyncScenarioOpenShift = GetSyncScenarioSetting "Open Shift"
$SyncScenarioOpenShiftRequest = GetSyncScenarioSetting "Open Shift Request"
$SyncScenarioShift = GetSyncScenarioSetting "Shift"
$SyncScenarioSwapRequest = GetSyncScenarioSetting "Swap Request"
$SyncScenarioTimeCard = GetSyncScenarioSetting "Time Card"
$SyncScenarioTimeOff = GetSyncScenarioSetting "Time Off"
$SyncScenarioTimeOffRequest = GetSyncScenarioSetting "Time Off Request"
$SyncScenarioUserShiftPreference = GetSyncScenarioSetting "User Shift Preferences"

#Read admin email list
[psobject[]]$AdminEmailList = @()
while ($true){
	$AdminEmail = Read-Host -Prompt "Enter admin's email to receive error report"
	$AdminEmailList += $AdminEmail
	$title    = 'Adding another email'
	$question = 'Would you like to add another admin email?'
	$choices  = '&Yes', '&No'
	$decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
	if ($decision -eq 1) {
		break
	}
}
$InstanceResponse = New-CsTeamsShiftsConnectionInstance `
	-ConnectionId $ConnectionId `
    -ConnectorAdminEmail $AdminEmailList `
    -DesignatedActorId $teamsUserId `
    -Name $InstanceName `
    -SyncFrequencyInMin $syncFreq `
	-SyncScenarioOpenShift $SyncScenarioOpenShift `
	-SyncScenarioOpenShiftRequest $SyncScenarioOpenShiftRequest `
	-SyncScenarioShift $SyncScenarioShift `
	-SyncScenarioSwapRequest $SyncScenarioSwapRequest `
	-SyncScenarioTimeCard $SyncScenarioTimeCard `
	-SyncScenarioTimeOff $SyncScenarioTimeOff `
	-SyncScenarioTimeOffRequest $SyncScenarioTimeOffRequest `
	-SyncScenarioUserShiftPreference $SyncScenarioUserShiftPreference

$InstanceId = $InstanceResponse.id
if ($null -ne $InstanceId){
    Write-Output "Success"
} else {
    throw "Connector instance creation failed"
}

#Keep mapping teams until user stops it
$mappings=@()
while ($true)
{
	#Create a new Teams team with owner set to system account and name set to the site name
	Write-Output "Creating a Teams team"
	$teamsTeamName = Read-Host -Prompt "Input the Teams team name"
	$Team = New-Team -DisplayName $teamsTeamName -Visibility "Public" -Owner $teamsUserId
	Write-Output "Successfully created a team"
	$TeamsTeamId=$Team.GroupId

	#Retrieve the list of wfm locations
	Write-Output "Listing the WFM team sites"
	$WfmTeamIds = Get-CsTeamsShiftsConnectionWfmTeam -ConnectorInstanceId $InstanceId
	Write-Output $WfmTeamIds
	if (($NULL -ne $WfmTeamIds) -and ($WfmTeamIds.Count -gt 0)){
		[System.String]$WfmTeamId = Read-Host -Prompt "Input the ID of WFM team you want to map"
	}
	else {
		throw "The WfmTeamId list is null or empty"
	}

	#Retrieve the list of WFM users and their roles
	Write-Output "Listing WFM users and roles"
	$WFMUsers = Get-CsTeamsShiftsConnectionWfmUser -ConnectorInstanceId $InstanceId -WfmTeamId $WfmTeamId
	Write-Output $WFMUsers

	#Add users to the Team for Shifts
	Write-Output "Adding users to Teams team"
	$currentUser = Read-Host -Prompt "Input the current user's user name or AAD ID"
	Add-TeamUser -GroupId $TeamsTeamId -User $currentUser -Role Owner
	$failedWfmUsers=@()
	foreach ($user in $WFMUsers) {
		try {
		$userEmail = $user.Name + "@" +$domain
		Add-TeamUser -GroupId $TeamsTeamId -User $userEmail
		} catch {
			$failedWfmUsers+=$user
		}
	}
	if($failedWfmUsers.Count -gt 0){
		Write-Output "There are WFM users not existed in Teams tenant:"
		Write-Output $failedWfmUsers
	}

	#Enable scheduling in the group
	$RequestBody = @{
		Enabled = $true
		TimeZone = "America/Los_Angeles"
	}
	$teamUpdateUrl="https://graph.microsoft.com/v1.0/teams/"+$TeamsTeamId+"/schedule"
	Invoke-MgGraphRequest -Uri $teamUpdateUrl -Method PUT -Body $RequestBody

	#Create a mapping of the new team to the instance
	Write-Output "Create a mapping of the new team to the site"
	$TimeZone = Read-Host -Prompt "Input the time zone of team mapping"
	$mapping = @{
		teamId = $TeamsTeamId
		wfmTeamId = $WfmTeamId
		timeZone = $TimeZone
		}
	$mappings += , $mapping

	$title    = 'Connecting another team'
	$question = 'Would you like to connect another team?'
	$choices  = '&Yes', '&No'

	$decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
	if ($decision -eq 1) {
		break
	}
}
$batchMappingResponse = New-CsTeamsShiftsConnectionBatchTeamMap -ConnectorInstanceId $InstanceId -TeamMapping @($mappings)
if ($null -ne $batchMappingResponse.OperationId){
	"The mapping has begun asynchronously. To query mapping results run Get-CsTeamsShiftsConnectionOperation with the operation Id."
}
else {
	throw "The mapping has failed due to validation errors."
}
Write-Output $batchMappingResponse

Remove-TeamUser -GroupId $TeamsTeamId -User $currentUser -Role Owner
Disconnect-MgGraph

Een verbinding instellen en een bestaand team toewijzen

#Map WFM sites to existing teams script
Write-Output "Map WFM sites to existing teams"
Start-Sleep 1

#Ensure Teams module is at least version x
Write-Output "Checking Teams module version"
try {
	Get-InstalledModule -Name "MicrosoftTeams" -MinimumVersion 5.2.0
} catch {
	throw
}

#Connect to MS Graph
Connect-MgGraph -Scopes "User.Read.All","Group.ReadWrite.All"

#List connector types available (comment out if not implemented for preview)
Write-Output "Listing connector types available"
$BlueYonderId = "6A51B888-FF44-4FEA-82E1-839401E9CD74"
$connectors = Get-CsTeamsShiftsConnectionConnector
Write-Output $connectors

#Prompt for entering of WFM username and password
$WfmUserName = Read-Host -Prompt 'Input your Blue Yonder account username'
$WfmPwd = Read-Host -Prompt 'Input your Blue Yonder account password' -AsSecureString
$plainPwd =[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($WfmPwd))

#Test connection settings
Write-Output "Testing connection settings"
$ConnectionName = Read-Host -Prompt 'Input connection name'
$adminApiUrl = Read-Host -Prompt 'Input admin api url'
$cookieAuthUrl = Read-Host -Prompt 'Input cookie authorization url'
$essApiUrl = Read-Host -Prompt 'Input ess api url'
$federatedAuthUrl = Read-Host -Prompt 'Input federated authorization url'
$retailWebApiUrl = Read-Host -Prompt 'Input retail web api url'
$siteManagerUrl = Read-Host -Prompt 'Input site manager url'

$testResult = Test-CsTeamsShiftsConnectionValidate `
	-Name $ConnectionName `
	-ConnectorId $BlueYonderId `
	-ConnectorSpecificSettings (New-Object Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Models.ConnectorSpecificBlueYonderSettingsRequest `
		-Property @{
			AdminApiUrl = $adminApiUrl
			SiteManagerUrl = $siteManagerUrl
			EssApiUrl = $essApiUrl
			RetailWebApiUrl = $retailWebApiUrl
			CookieAuthUrl = $cookieAuthUrl
			FederatedAuthUrl = $federatedAuthUrl
			LoginUserName = $WfmUserName
			LoginPwd = $plainPwd
		})
		
if ($NULL -ne $testResult.Code) {
	Write-Output $testResult
	throw "Validation failed, conflict found"
}
Write-Host "Test complete, no conflicts found"

#Create a connection
Write-Output "Creating a connection"
$ConnectionResponse = New-CsTeamsShiftsConnection `
    -Name $ConnectionName `
    -ConnectorId $BlueYonderId `
    -ConnectorSpecificSettings (New-Object Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Models.ConnectorSpecificBlueYonderSettingsRequest `
		-Property @{
			AdminApiUrl = $adminApiUrl
			SiteManagerUrl = $siteManagerUrl
			EssApiUrl = $essApiUrl
			RetailWebApiUrl = $retailWebApiUrl
			CookieAuthUrl = $cookieAuthUrl
			FederatedAuthUrl = $federatedAuthUrl
			LoginUserName = $WfmUserName
			LoginPwd = $plainPwd
		})

$ConnectionId = $ConnectionResponse.Id
if ($null -ne $ConnectionId){
	Write-Output "Successfully created connection"
} else {
	throw "Connection creation failed"
}

#Create a connection instance
Write-Output "Creating a connection instance"
$designatedActorName = Read-Host -Prompt "Input Microsoft 365 System Account (person@contoso.com)"
$designator = Get-MgUser -UserId $designatedActorName
$teamsUserId = $designator.Id
$syncFreq = Read-Host -Prompt "Input sync frequency in minutes"
$InstanceName = Read-Host -Prompt "Input connection instance name"

#Read sync scenarios for connection instance
function GetSyncScenarioSetting {
	param (
		$SettingName
	)
	$TwoWay = New-Object System.Management.Automation.Host.ChoiceDescription '&TwoWay', 'TwoWay'
	$Disabled = New-Object System.Management.Automation.Host.ChoiceDescription '&Disabled', 'Disabled'
	$FromWfmToShifts = New-Object System.Management.Automation.Host.ChoiceDescription '&FromWfmToShifts', 'FromWfmToShifts'
	$options = [System.Management.Automation.Host.ChoiceDescription[]]($TwoWay, $Disabled, $FromWfmToShifts)
	$result = $host.ui.PromptForChoice("Set sync scenario for $SettingName", "", $options, 0)

	switch ($result)
	{
		0 { return "TwoWay" }
		1 { return "Disabled" }
		2 { return "FromWfmToShifts" }
	}
}
$SyncScenarioOpenShift = GetSyncScenarioSetting "Open Shift"
$SyncScenarioOpenShiftRequest = GetSyncScenarioSetting "Open Shift Request"
$SyncScenarioShift = GetSyncScenarioSetting "Shift"
$SyncScenarioSwapRequest = GetSyncScenarioSetting "Swap Request"
$SyncScenarioTimeCard = GetSyncScenarioSetting "Time Card"
$SyncScenarioTimeOff = GetSyncScenarioSetting "Time Off"
$SyncScenarioTimeOffRequest = GetSyncScenarioSetting "Time Off Request"
$SyncScenarioUserShiftPreference = GetSyncScenarioSetting "User Shift Preferences"

#Read admin email list
[psobject[]]$AdminEmailList = @()
while ($true){
	$AdminEmail = Read-Host -Prompt "Enter admin's email to receive error report"
	$AdminEmailList += $AdminEmail
	$title    = 'Adding another email'
	$question = 'Would you like to add another admin email?'
	$choices  = '&Yes', '&No'
	$decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
	if ($decision -eq 1) {
		break
	}
}
$InstanceResponse = New-CsTeamsShiftsConnectionInstance `
	-ConnectionId $ConnectionId `
    -ConnectorAdminEmail $AdminEmailList `
    -DesignatedActorId $teamsUserId `
    -Name $InstanceName `
    -SyncFrequencyInMin $syncFreq `
	-SyncScenarioOpenShift $SyncScenarioOpenShift `
	-SyncScenarioOpenShiftRequest $SyncScenarioOpenShiftRequest `
	-SyncScenarioShift $SyncScenarioShift `
	-SyncScenarioSwapRequest $SyncScenarioSwapRequest `
	-SyncScenarioTimeCard $SyncScenarioTimeCard `
	-SyncScenarioTimeOff $SyncScenarioTimeOff `
	-SyncScenarioTimeOffRequest $SyncScenarioTimeOffRequest `
	-SyncScenarioUserShiftPreference $SyncScenarioUserShiftPreference

$InstanceId = $InstanceResponse.id
if ($null -ne $InstanceId){
    Write-Output "Success"
} else {
    throw "Connector instance creation failed"
}

#Keep mapping teams until user stops it
$mappings=@()
while ($true)
{
	$TeamsTeamId = Read-Host -Prompt "Input the ID of the Teams team to be mapped"
	#Clear schedule of the Teams team
	Write-Host "Clear schedule of the existing team"

	$entityTypeString = Read-Host -Prompt 'Input the entity types of clear schedule'
	$Delimiters = ",", ".", ":", ";", " ", "`t"
	$entityType = $entityTypeString -Split {$Delimiters -contains $_}
	$entityType = $entityType.Trim()
	$entityType = $entityType.Split('',[System.StringSplitOptions]::RemoveEmptyEntries)
	Remove-CsTeamsShiftsScheduleRecord -TeamId $TeamsTeamId -ClearSchedulingGroup:$True -EntityType $entityType

	#Retrieve the list of wfm locations
	Write-Output "Listing the WFM team sites"
	$WfmTeamIds = Get-CsTeamsShiftsConnectionWfmTeam -ConnectorInstanceId $InstanceId
	Write-Output $WfmTeamIds
	if (($NULL -ne $WfmTeamIds) -and ($WfmTeamIds.Count -gt 0)){
		[System.String]$WfmTeamId = Read-Host -Prompt "Input the ID of WFM team you want to map"
	}
	else {
		throw "The WfmTeamId list is null or empty"
	}

	#Retrieve the list of WFM users and their roles
	Write-Output "Listing WFM users and roles"
	$WFMUsers = Get-CsTeamsShiftsConnectionWfmUser -ConnectorInstanceId $InstanceId -WfmTeamId $WfmTeamId
	Write-Output $WFMUsers

	#Create a mapping of the existing team to the instance
	Write-Host "Create a mapping of the existing team to the site"
	$TimeZone = Read-Host -Prompt "Input the time zone of team mapping"
	$mapping = @{
		teamId = $TeamsTeamId
		wfmTeamId = $WfmTeamId
		timeZone = $TimeZone
		}
	$mappings += , $mapping

	$title    = 'Connecting another team'
	$question = 'Would you like to connect another team?'
	$choices  = '&Yes', '&No'

	$decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
	if ($decision -eq 1) {
		break
	}
}
$batchMappingResponse = New-CsTeamsShiftsConnectionBatchTeamMap -ConnectorInstanceId $InstanceId -TeamMapping @($mappings)
if ($null -ne $batchMappingResponse.OperationId){
	"The mapping has begun asynchronously. To query mapping results run Get-CsTeamsShiftsConnectionOperation with the operation Id."
}
else {
	throw "The mapping has failed due to validation errors."
}
Write-Output $batchMappingResponse

Disconnect-MgGraph

Cmdlets voor Diensten-connector

Zoek naar CsTeamsShiftsConnection in de Teams PowerShell-cmdlet-documentatie voor hulp bij Diensten-connector-cmdlets. Hier volgen koppelingen naar enkele veelgebruikte cmdlets, gegroepeerd op categorie:

Verbindingen

referenties voor WFM systemen

Synchronisatieopties voor ondersteunde scenario's

Planningsgegevens verwijderen

Verbindingsexemplaren

Gebruikerstoewijzing en geslaagde synchronisatie

Teamtoewijzing

Bewerkings-id

Foutrapporten