Delen via


PowerShell gebruiken om Shifts te verbinden met UKG Pro Workforce Management

Overzicht

Gebruik de Microsoft Teams Shifts-connector voor UKG Pro Workforce Management om de Shifts-app in Microsoft Teams te integreren met UKG Pro Workforce Management (UKG Pro WFM). Uw frontlijnmedewerkers kunnen hun planningen in UKG Pro naadloos bekijken en beheren WFM vanuit Shifts.

In dit artikel wordt uitgelegd hoe u PowerShell gebruikt om de connector in te stellen en te configureren om Shifts te integreren met UKG Pro WFM.

Als je de verbinding wilt instellen, voer je een PowerShell-script uit. Het script configureert de connector, past synchronisatie-instellingen toe, maakt de verbinding en wijst UKG Pro WFM exemplaren (ook wel WFM exemplaren genoemd) toe aan teams in Teams. Synchronisatie-instellingen bepalen de functies die zijn ingeschakeld in Shifts en de planningsgegevens die worden gesynchroniseerd tussen UKG Pro WFM en Shifts. Toewijzingen definiëren de synchronisatierelatie tussen uw 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 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 UKG Pro WFM als recordsysteem kunnen uw frontlijnmedewerkers hun planningen en beschikbaarheid in Shifts op hun apparaten efficiënt beheren. Frontlinemanagers kunnen UKG Pro WFM blijven gebruiken om planningen in te stellen.

Opmerking

U kunt ook de wizard Shifts-connector in de Microsoft 365-beheercentrum gebruiken om Shifts te verbinden met UKG Pro WFM.

Voordat u begint

Vereisten

Neem de tijd om de informatie te bekijken en alle vereiste en configuratietaken te voltooien in Vereisten en vereisten voor de Teams Shifts-connector voor UKG Pro Workforce Management.

Zorg ervoor dat u alle taken voltooit voordat u de stappen in dit artikel uitvoert.

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 enMicrosoft 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 Microsoft 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 u WFM exemplaren toegeeft aan bestaande teams. 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 WFM-exemplaar wilt toewijzen aan het nieuwe team, voert u het nieuwe teams-script uit.
  • Als u een verbinding wilt instellen en 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 UKG Pro WFM met behulp van de UKG Pro WFM serviceaccountreferenties en service-URL's die u invoert.

  2. Synchronisatie-instellingen toepassen. Deze instellingen omvatten de synchronisatiefrequentie (in minuten) en de planningsgegevens die zijn gesynchroniseerd tussen UKG Pro WFM en Shifts. U kunt planningsgegevens inschakelen die zijn gedefinieerd door deze scenario's: Shift, SwapRequestOfferShiftRequest, UserShiftPreferences, 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. Zie PowerShell gebruiken voor het beheren van uw Shifts-verbinding met UKG Pro Workforce Management voor meer informatie.

  3. Wijs 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 WFM 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 De Microsoft 365-beheercentrum gebruiken om uw Shifts-verbinding met UKG Pro Workforce Management 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. Zie PowerShell gebruiken voor het beheren van uw Shifts-verbinding met UKG Pro Workforce Management voor stapsgewijze instructies.

Scripts

Een verbinding instellen en een nieuw team maken

#Map WFM instances 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
Write-Output "Listing connector types available"
$UkgId = "95BF2848-2DDA-4425-B0EE-D62AEED4C0A0"
$connectors = Get-CsTeamsShiftsConnectionConnector
Write-Output $connectors
$Ukg = $connectors | Where-Object {$_.Id -match $UkgId}
if ($NULL -eq $Ukg) {
    throw "UKG Dimensions not currently supported"
}

#Prompt for entering of WFM username and password
$WfmUserName = Read-Host -Prompt 'Input your UKG account username'
$WfmPwd = Read-Host -Prompt 'Input your UKG 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'
$apiUrl = Read-Host -Prompt 'Input connector api url'
$ssoUrl = Read-Host -Prompt 'Input connector sso url'
$clientId = Read-Host -Prompt 'Input connector client id'
$AppKey = Read-Host -Prompt 'Input your app key' -AsSecureString
$plainKey =[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($AppKey))
$ClientSecret = Read-Host -Prompt 'Input your client secret' -AsSecureString
$plainSecret =[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($ClientSecret))

$testResult = Test-CsTeamsShiftsConnectionValidate `
    -Name $ConnectionName `
    -ConnectorId $UkgId `
    -ConnectorSpecificSettings (New-Object Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Models.ConnectorSpecificUkgDimensionsSettingsRequest `
        -Property @{
            apiUrl = $apiUrl
            ssoUrl = $ssoUrl
            appKey = $plainKey
            clientId = $clientId
            clientSecret = $plainSecret
            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 $UkgId `
    -ConnectorSpecificSettings (New-Object Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Models.ConnectorSpecificUkgDimensionsSettingsRequest `
        -Property @{
            apiUrl = $apiUrl
            ssoUrl = $ssoUrl
            appKey = $plainKey
            clientId = $clientId
            clientSecret = $plainSecret
            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" }
    }
}
$SyncScenarioOfferShiftRequest = GetSyncScenarioSetting "Offer Shift Request"
$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 `
    -SyncScenarioOfferShiftRequest $SyncScenarioOfferShiftRequest `
    -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 instances to existing teams script
Write-Host "Map WFM sites to existing teams"
Start-Sleep 1

#Ensure Teams module is at least version x
Write-Host "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
Write-Output "Listing connector types available"
$UkgId = "95BF2848-2DDA-4425-B0EE-D62AEED4C0A0"
$connectors = Get-CsTeamsShiftsConnectionConnector
Write-Output $connectors
$Ukg = $connectors | Where-Object {$_.Id -match $UkgId}
if ($NULL -eq $Ukg) {
    throw "UKG Dimensions not currently supported"
}

#Prompt for entering of WFM username and password
$WfmUserName = Read-Host -Prompt 'Input your UKG account username'
$WfmPwd = Read-Host -Prompt 'Input your UKG 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'
$apiUrl = Read-Host -Prompt 'Input connector api url'
$ssoUrl = Read-Host -Prompt 'Input connector sso url'
$clientId = Read-Host -Prompt 'Input connector client id'
$AppKey = Read-Host -Prompt 'Input your app key' -AsSecureString
$plainKey =[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($AppKey))
$ClientSecret = Read-Host -Prompt 'Input your client secret' -AsSecureString
$plainSecret =[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($ClientSecret))

$testResult = Test-CsTeamsShiftsConnectionValidate `
    -Name $ConnectionName `
    -ConnectorId $UkgId `
    -ConnectorSpecificSettings (New-Object Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Models.ConnectorSpecificUkgDimensionsSettingsRequest `
        -Property @{
            apiUrl = $apiUrl
            ssoUrl = $ssoUrl
            appKey = $plainKey
            clientId = $clientId
            clientSecret = $plainSecret
            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 $UkgId `
    -ConnectorSpecificSettings (New-Object Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Models.ConnectorSpecificUkgDimensionsSettingsRequest `
        -Property @{
            apiUrl = $apiUrl
            ssoUrl = $ssoUrl
            appKey = $plainKey
            clientId = $clientId
            clientSecret = $plainSecret
            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" }
    }
}
$SyncScenarioOfferShiftRequest = GetSyncScenarioSetting "Offer Shift Request"
$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 `
    -SyncScenarioOfferShiftRequest $SyncScenarioOfferShiftRequest `
    -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:

Connections

referenties voor WFM systemen

Synchronisatieopties voor ondersteunde scenario's

Planningsgegevens verwijderen

Verbindingsexemplaren

Gebruikerstoewijzing en geslaagde synchronisatie

Teamtoewijzing

Bewerkings-id

Foutrapporten