Brug PowerShell til at forbinde skift til UKG Pro Workforce Management
Oversigt
Brug Microsoft Teams Shifts-connectoren til UKG Pro Workforce Management til at integrere Shifts-appen i Microsoft Teams med UKG Pro Workforce Management (UKG Pro WFM). Dine frontlinjemedarbejdere kan uden problemer få vist og administrere deres tidsplaner i UKG Pro WFM fra Skift.
I denne artikel gennemgår vi, hvordan du bruger PowerShell til at konfigurere connectoren til at integrere Shifts med UKG Pro WFM.
Hvis du vil konfigurere forbindelsen, skal du køre et PowerShell-script. Scriptet konfigurerer connectoren, anvender synkroniseringsindstillinger, opretter forbindelsen og knytter UKG Pro WFM-forekomster (også kaldet WFM-forekomster) til teams i Teams. Synkroniseringsindstillinger bestemmer de funktioner, der er aktiveret i Skift, og de tidsplanoplysninger, der synkroniseres mellem UKG Pro WFM og Skift. Tilknytninger definerer synkroniseringsrelationen mellem dine WFM-instanser og -teams i Teams. Du kan knytte til eksisterende teams og nye teams.
Vi leverer to scripts. Du kan bruge begge scripts, afhængigt af om du vil knytte til eksisterende teams eller oprette nye teams, der skal tilknyttes.
Du kan konfigurere flere forbindelser, der hver især har forskellige synkroniseringsindstillinger. Hvis din organisation f.eks. har flere placeringer med forskellige tidsplankrav, skal du oprette en forbindelse med entydige synkroniseringsindstillinger for hver placering. Vær opmærksom på, at en WFM-forekomst kun kan knyttes til ét team på et givet tidspunkt. Hvis en forekomst allerede er knyttet til et team, kan den ikke knyttes til et andet team.
Med UKG Pro WFM som postsystem kan dine frontlinjemedarbejdere effektivt administrere deres tidsplaner og tilgængelighed i Skift på deres enheder. Frontline-ledere kan fortsætte med at bruge UKG Pro WFM til at konfigurere tidsplaner.
Bemærk!
Du kan også bruge guiden Skifts-connector i Microsoft 365 Administration til at oprette forbindelse mellem Skift og UKG Pro WFM.
Før du begynder
Forudsætninger
Tag dig tid til at gennemse oplysningerne og fuldføre alle forudsætnings- og konfigurationsopgaver i Forudsætninger og krav til Teams Shifts-connectoren til UKG Pro Workforce Management.
Sørg for, at du udfører alle opgaverne, før du følger trinnene i denne artikel.
Administratorrolle til administration af connectoren ved hjælp af PowerShell
Du skal være global Microsoft 365-administrator eller administrator af Shifts-connectoren for at fuldføre trinnene i denne artikel.
Rollen Shifts-connectoradministrator er en brugerdefineret rolle, som du opretter i Microsoft Entra ID og tildeler til en bruger. Navnet på rollen skal være "Skifts connector-administrator". Rollen behøver ikke at have specifikke tilladelser, selvom der skal angives mindst én tilladelse, når du opretter den. Tjenesten er afhængig af tilstedeværelsen af rollen på brugeren og ikke dens tilladelser.
Du kan få mere at vide under Opret og tildel en brugerdefineret rolle i Microsoft Entra ID og Tildel Microsoft Entra-roller til brugere. Vær opmærksom på, at det kan tage op til 24 timer, før rollen oprettes og anvendes på en bruger.
Vigtigt!
Microsoft anbefaler, at du bruger roller med færrest tilladelser. Dette hjælper med at forbedre sikkerheden for din organisation. Global administrator er en yderst privilegeret rolle, der bør være begrænset til nødscenarier, når du ikke kan bruge en rolle, der er mindre privilegeret.
Konfigurer dit miljø
Installér PowerShell version 7 eller nyere. Du kan finde en trinvis vejledning under Installation af PowerShell på Windows.
Kør PowerShell i administratortilstand.
Installér Microsoft Graph PowerShell-modulet.
Install-Module Microsoft.Graph Import-Module Microsoft.Graph
Kontrollér, at det er version 1.6.1 eller nyere.
Get-InstalledModule Microsoft.Graph
Installér Teams Preview PowerShell-modulet.
Install-Module -Name MicrosoftTeams -AllowPrerelease -Force Import-Module MicrosoftTeams
Kontrollér, at den er mindst version 4.7.0 og indeholder Shifts-connector-cmdlet'erne.
Get-Command -Module MicrosoftTeams -Name *teamsshiftsconnection*
Indstil PowerShell til at afslutte, hvis der opstår en fejl, når scriptet køres.
$ErrorActionPreference = "Stop"
Aktivér scripts til at køre i Windows.
Set-ExecutionPolicy bypass
Opret forbindelse til Teams
Kør følgende for at oprette forbindelse til Microsoft Teams.
Connect-MicrosoftTeams
Når du bliver bedt om det, skal du logge på med dine administratorlegitimationsoplysninger. Du er nu konfigureret til at køre scripts i denne artikel og Shifts-connector-cmdlet'er.
Identificer de teams, du vil tilknytte
Bemærk!
Fuldfør dette trin, hvis du knytter WFM-forekomster til eksisterende teams. Hvis du opretter nye teams, der skal tilknyttes, kan du springe dette trin over.
På Azure Portal skal du gå til siden Alle grupper for at få vist en liste over TeamId'er for teams i din organisation.
Notér TeamId'erne for de teams, du vil tilknytte. Scriptet beder dig om at angive disse oplysninger.
Bemærk!
Hvis et eller flere teams har en eksisterende tidsplan, fjerner scriptet tidsplanerne fra disse teams. Ellers kan du se dublerede skift.
Kør scriptet
Kør et af følgende scripts, afhængigt af om du opretter et nyt team eller knytter til et eksisterende team:
- Hvis du vil konfigurere en forbindelse, oprette et nyt team i Teams og knytte en WFM-forekomst til det nye team, skal du køre scriptet for det nye teams.
- Hvis du vil konfigurere en forbindelse og knytte WFM-forekomster til eksisterende teams i Teams, skal du køre det eksisterende teamsscript.
Følg vejledningen på skærmen, når du kører scriptet. Scriptet fuldfører følgende handlinger:
Test og bekræft forbindelsen til UKG Pro WFM ved hjælp af de UKG Pro WFM-tjenestekontooplysninger og tjeneste-URL-adresser, du angiver.
Anvend synkroniseringsindstillinger. Disse indstillinger omfatter synkroniseringshyppigheden (i minutter) og de tidsplandata, der synkroniseres mellem UKG Pro WFM og Skift. Du kan aktivere tidsplandata, der defineres af disse scenarier:
Shift
,SwapRequest
,OfferShiftRequest
,UserShiftPreferences
,OpenShift
,OpenShiftRequest
,TimeOff
,TimeOffRequest
.Du kan få mere at vide under New-CsTeamsShiftsConnectionInstance. Hvis du vil se en liste over understøttede synkroniseringsindstillinger for hver parameter, skal du køre Get-CsTeamsShiftsConnectionConnector.
Bemærk!
Scriptet aktiverer synkronisering for hver understøttet synkroniseringsindstilling. Hvis du vil ændre synkroniseringsindstillingerne, kan du gøre det, når forbindelsen er oprettet. Du kan få mere at vide under Brug PowerShell til at administrere din Skift-forbindelse til UKG Pro Workforce Management.
Knyt WFM-forekomster til dine teams i Teams.
- Hvis du vælger at køre scriptet for nye teams for at oprette nye teams, er tilknytninger baseret på de nye teams, du opretter.
- Hvis du vælger at køre det eksisterende teamsscript for at tilknytte eksisterende teams, er tilknytninger baseret på WFM-forekomst-id'er og TeamId'er, som du angiver. Hvis et team har en eksisterende tidsplan, fjerner scriptet alle tidsplandata.
Når du har kørt scriptet, bekræfter en meddelelse om, at forbindelsen er oprettet.
Administrer din forbindelse
Når en forbindelse er konfigureret, kan du administrere og foretage ændringer af den i Microsoft 365 Administration eller ved hjælp af PowerShell.
Brug Microsoft 365 Administration
På siden Connectorstyring vises hver forbindelse, du har konfigureret, sammen med oplysninger som f.eks. tilstandsstatus og oplysninger om synkroniseringsintervaller. Du kan også få adgang til guiden for at foretage ændringer af dine forbindelser. Du kan f.eks. opdatere synkroniseringsindstillinger og teamtilknytninger.
Du kan få mere at vide under Brug Microsoft 365 Administration til at administrere din Skift-forbindelse til UKG Pro Workforce Management.
Brug PowerShell
Du kan bruge PowerShell til at få vist en fejlrapport, ændre forbindelsesindstillinger, deaktivere synkronisering og meget mere. Du kan finde en trinvis vejledning under Brug PowerShell til at administrere din Skift-forbindelse til UKG Pro Workforce Management.
Scripts
Konfigurer en forbindelse, og opret et nyt team
#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
Konfigurer en forbindelse, og tilknyt et eksisterende team
#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
Skifter forbindelses-cmdlet'er
Hvis du vil have hjælp til Shifts-connector-cmdlet'er, herunder de cmdlet'er, der bruges i scripts, skal du søge efter CsTeamsShiftsConnection i Reference til Teams PowerShell-cmdlet'en. Her er links til nogle almindeligt anvendte cmdlet'er grupperet efter kategori:
Forbindelser
Legitimationsoplysninger til WFM-systemer
Synkroniseringsindstillinger for understøttede scenarier
Fjern plandata
Forbindelsesforekomster
- New-CsTeamsShiftsConnectionInstance
- Get-CsTeamsShiftsConnectionInstance
- Set-CsTeamsShiftsConnectionInstance
- Update-CsTeamsShiftsConnectionInstance
- Fjern-CsTeamsShiftsConnectionInstance
Brugertilknytning og vellykket synkronisering
Gruppetilknytning
Handlings-id
Fejlrapporter
Relaterede artikler
- Vagtforbindelser
- Brug PowerShell til at administrere din Skift-forbindelse til UKG Pro Workforce Management
- Brug Microsoft 365 Administration til at administrere din Skift-forbindelse til UKG Pro Workforce Management
- Administrer appen Vagter
- Oversigt over Teams PowerShell
- Reference til Teams PowerShell-cmdlet