שימוש ב- PowerShell לחיבור Shifts ל- UKG Pro Workforce Management

סקירה כללית

השתמש במחבר Microsoft Teams Shifts עבור UKG Pro Workforce Management כדי לשלב את האפליקציה Shifts ב- Microsoft Teams עם UKG Pro Workforce Management (UKG Pro WFM). העובדים בחזית יכולים להציג ולנהל בצורה חלקה את לוחות הזמנים שלהם ב- UKG Pro WFM מתוך Shifts.

במאמר זה, נדריך אותך כיצד להשתמש ב- PowerShell כדי להגדיר ולהגדיר את המחבר כך שישלב את Shifts עם UKG Pro WFM.

כדי להגדיר את החיבור, הפעל קובץ Script של PowerShell. קובץ ה- Script קובע את תצורת המחבר, מחיל הגדרות סינכרון, יוצר את החיבור וממפה מופעי UKG Pro WFM (נקראים גם מופעי WFM) על צוותים ב- Teams. הגדרות הסינכרון קובעות את התכונות הזמינות ב- Shifts ואת פרטי לוח הזמנים שסונכרנו בין UKG Pro WFM Shifts. מיפויים מגדירים את קשר הסינכרון בין WFM שלך לבין צוותים ב- Teams. באפשרותך למפות לצוותים קיימים ולקבוצות חדשות.

אנו מספקים שני תסריטים. באפשרותך להשתמש בכל קובץ Script, בהתאם לשאלה אם ברצונך למפות לצוותים קיימים או ליצור צוותים חדשים שאליהם ברצונך למפות.

באפשרותך להגדיר חיבורים מרובים, שכל אחד מהם כולל הגדרות סינכרון שונות. לדוגמה, אם לארגון שלך יש מיקומים מרובים עם דרישות לוח זמנים שונות, צור חיבור עם הגדרות סינכרון ייחודיות עבור כל מיקום. זכור שניתן למפות WFM אחד בלבד לצוות אחד בכל זמן נתון. אם מופע כבר ממופה לצוות, לא ניתן למפות אותו לצוות אחר.

כאשר UKG Pro WFM מערכת ההקלטה, העובדים בחזית העסק יכולים לנהל ביעילות את לוחות הזמנים והזמינות שלהם ב- Shifts במכשירים שלהם. מנהלי קו החזית יכולים להמשיך להשתמש ב- UKG Pro WFM להגדיר לוחות זמנים.

הערה

באפשרותך גם להשתמש באשף מחבר Shifts בחלונית מרכז הניהול של Microsoft 365 כדי לחבר את Shifts ל- UKG Pro WFM.

לפני שתתחיל

דרישות מוקדמות

התזמן כדי לסקור את המידע ולהשלים את כל משימות התצורה והדרישות המוקדמות בדרישות המוקדמות ובדרישות עבור מחבר Teams Shifts עבור מנהל ה- UKG Pro Workforce Management.

הקפד להשלים את כל המשימות לפני ביצוע השלבים במאמר זה.

מרכז הניהול תפקיד בניהול המחבר באמצעות PowerShell

עליך להיות מנהל מערכת כללי של Microsoft 365 או מנהל מחבר של Shifts כדי להשלים את השלבים המפורטים במאמר זה.

תפקיד הניהול של מחבר Shifts הוא תפקיד מותאם אישית שאתה יוצר Microsoft Entra מזהה ומקצה אותו למשתמש. שם התפקיד חייב להיות "מנהל מחבר Shifts". התפקיד אינו חייב להיות בעל הרשאות ספציפיות, למרות שיש להגדיר לפחות הרשאה אחת בעת יצירתו. השירות מסתמך על הנוכחות של התפקיד על המשתמש, ולא על ההרשאות שלו.

לקבלת מידע נוסף, ראה יצירה והקצאה של תפקיד מותאם אישית Microsoft Entra מזההוהקצאת Microsoft Entra למשתמשים. זכור כי ייתכן שידרשו עד 24 שעות עד שהתפקיד ייווצר ויחול על משתמש.

הגדרת הסביבה שלך

  1. התקן את PowerShell גירסה 7 ואילך. לקבלת הדרכה שלב אחר שלב, ראה התקנת PowerShell ב- Windows.

  2. הפעל את PowerShell במצב מנהל מערכת.

  3. התקן את המודול Microsoft Graph PowerShell.

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

    ודא שגירסה זו היא גירסה 1.6.1 ואילך.

    Get-InstalledModule Microsoft.Graph 
    
  4. התקן את מודול PowerShell של תצוגה מקדימה של Teams.

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

    ודא שגירסה 4.7.0 לפחות מכילה את רכיבי ה- cmdlet של מחבר Shifts.

    Get-Command -Module MicrosoftTeams -Name *teamsshiftsconnection* 
    
  5. הגדר את PowerShell ליציאה אם מתרחשת שגיאה בעת הפעלת קובץ ה- Script.

    $ErrorActionPreference = "Stop" 
    
  6. אפשר הפעלה של קבצי Script ב- Windows.

    Set-ExecutionPolicy bypass 
    

התחבר ל- Teams

הפעל את הפעולות הבאות כדי להתחבר ל- Microsoft Teams.

Connect-MicrosoftTeams

כשתתבקש, היכנס באמצעות אישורי מנהל המערכת שלך. כעת אתה מוגדר להפעיל את קבצי ה- Script במאמר זה ואת רכיבי ה- cmdlet של מחבר Shifts.

זהה את הצוותים שברצונך למפות

הערה

בצע שלב זה אם אתה ממפה WFM אלה לצוותים קיימים. אם אתה יוצר צוותים חדשים למיפוי, באפשרותך לדלג על שלב זה.

בפורטל Azure, עבור אל הדף 'כל הקבוצות ' כדי לקבל רשימה של TeamIds של צוותים בארגון שלך.

רשום לעצמך את מזהה הצוות של הצוותים שברצונך למפות. קובץ ה- Script יבקש ממך להזין מידע זה.

הערה

אם לצוות אחד או יותר יש לוח זמנים קיים, קובץ ה- Script יסיר את לוחות הזמנים מקבוצות אלה. אחרת, תראה משמרות כפולות.

הפעל את קובץ ה- Script

הפעל אחד מתרחישי ה- Script הבאים, בהתאם לשאלה אם אתה יוצר צוות חדש או ממפה לצוות קיים:

  • כדי להגדיר חיבור, צור צוות חדש ב- Teams ומפה מופע WFM לצוות החדש, הפעל את קובץ ה- Script החדש של Teams.
  • כדי להגדיר חיבור ומפה בין WFM לצוותים קיימים ב- Teams, הפעל את קובץ ה- Script הקיים של Teams.

בצע את ההוראות המוצגות על המסך בעת הפעלת קובץ ה- Script. קובץ ה- Script משלים את הפעולות הבאות:

  1. בדוק ואמת את החיבור ל- UKG Pro WFM באמצעות האישורים של חשבון שירות WFM UKG Pro וכתובות URL של שירות שאתה מזין.

  2. החל הגדרות סינכרון. הגדרות אלה כוללות את תדירות הסינכרון (בדקות) ואת נתוני לוח הזמנים שסונכרנו בין UKG Pro WFM ו- Shifts. באפשרותך להפעיל נתוני תזמון המוגדרים על-ידי תרחישים אלה: Shift, SwapRequest, OfferShiftRequest, UserShiftPreferences, OpenShiftRequestOpenShift, TimeOff. TimeOffRequest

    לקבלת מידע נוסף, ראה New-CsTeamsShiftsConnectionInstance. כדי לראות את רשימת אפשרויות הסינכרון הנתמכות עבור כל פרמטר, הפעל את Get-CsTeamsShiftsConnectionConnector.

    הערה

    קובץ ה- Script מאפשר סינכרון עבור כל אפשרות סינכרון נתמכת. אם ברצונך לשנות את הגדרות הסינכרון, תוכל לעשות זאת לאחר הגדרת החיבור. לקבלת מידע נוסף, ראה שימוש ב- PowerShell לניהול חיבור Shifts ל- UKG Pro Workforce Management.

  3. מפה WFM מופעים לצוותים שלך ב- Teams.

    • אם בחרת להפעיל את קובץ ה - Script החדש של Teams כדי ליצור צוותים חדשים, המיפויים מבוססים על הצוותים החדשים שאתה יוצר.
    • אם בחרת להפעיל את קובץ ה- Script הקיים של Teams כדי למפות צוותים קיימים, המיפויים מבוססים על WFM מופעים ומפרטי TeamId שאתה מזין. אם לצוות יש לוח זמנים קיים, קובץ ה- Script מסיר את כל נתוני לוח הזמנים.

לאחר הפעלת קובץ ה- Script, הודעת הצלחה מאשרת אם החיבור הוגדר בהצלחה.

נהל את החיבור שלך

לאחר הגדרת חיבור, באפשרותך לנהל אותו ולבצע בו שינויים ב- מרכז הניהול של Microsoft 365 או באמצעות PowerShell.

השתמש מרכז הניהול של Microsoft 365

הדף 'ניהול מחברים' מפרט כל חיבור שאתה מגדיר, יחד עם מידע כגון מצב תקינות ופרטי מרווחי סינכרון. באפשרותך גם לגשת לאשף כדי לבצע שינויים בכל אחד מהחיבורים שלך. לדוגמה, באפשרותך לעדכן הגדרות סינכרון ומיפויי צוות.

לקבלת מידע נוסף, ראה שימוש מרכז הניהול של Microsoft 365 כדי לנהל את חיבור Shifts ל- UKG Pro Workforce Management.

שימוש ב- PowerShell

באפשרותך להשתמש ב- PowerShell כדי להציג דוח שגיאות, לשנות הגדרות חיבור, להפוך סינכרון ללא זמין ועוד. לקבלת הדרכה שלב אחר שלב, ראה שימוש ב- PowerShell לניהול חיבור Shifts ל- UKG Pro Workforce Management.

סקריפטים

הגדרת חיבור וייצור צוות חדש

#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

הגדרת חיבור ומפה צוות קיים

#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

רכיבי cmdlet של מחבר Shifts

לקבלת עזרה עבור רכיבי cmdlet של מחבר Shifts, כולל רכיבי ה- cmdlet המשמשים בקבצי ה- Script, חפש את CsTeamsShiftsConnection בהפניית ה- cmdlet של Teams PowerShell. להלן קישורים לרכיבי cmdlet נפוצים, מקובצים לפי קטגוריה:

Connections

WFM אישורי מערכות

אפשרויות סינכרון עבור תרחישים נתמכים

הסרת נתוני לוח זמנים

מופעי חיבור

מיפוי משתמש וסינכרון מוצלח

מיפוי צוות

מזהה פעולה

דוחות שגיאה