Provisioning Shifts (schedule) for a Microsoft Team via PowerShell

%3CLINGO-SUB%20id%3D%22lingo-sub-1506392%22%20slang%3D%22en-US%22%3EProvisioning%20Shifts%20(schedule)%20for%20a%20Microsoft%20Team%20via%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1506392%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3A)%3C%2Fimg%3E%20I%20am%20trying%20to%20provision%20Shifts%20(schedule)%20for%20Teams.%20The%20overall%20script%20creates%20a%20new%20Team%2C%20then%20passes%20the%20ID%20to%20the%20shifts%20piece.%20But%20I%20cannot%2C%20for%20the%20life%20of%20me%2C%20find%20a%20way%20to%20provision%20it.%20Here's%20my%20code%20(using%20a%20hard%20coded%20ID%20till%20I%20figure%20out%20what's%20up.)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUltimately%2C%20this%20will%20be%20part%20of%20a%20script%20that%20creates%20several%20Teams%2C%20each%20needing%20to%20have%20Shifts%20enabled.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhere%20I%20start%20%3CEM%3E%23%20THIS%20IS%20WHERE%20I'M%20STUCK%20%23%3C%2FEM%3E%26nbsp%3Bin%20my%20code%2C%26nbsp%3Btrying%20to%20work%20with%20the%20%22Enabled%22%20parameter%2C%20I%20have%20tried%20to%20use%20%24true%2C%201%2C%20nothing%2C%20%22yes%22.%20Nothing%20works.%20If%20I%20don't%20leave%20the%20space%20null%20after%20-Enabled%2C%20I%20get%20an%20error%20%22%3CU%3EUpdate-MgTeamSchedule%20%3A%20A%20positional%20parameter%20cannot%20be%20found%20that%20accepts%20argument%20'True'%3C%2FU%3E%22%20(or%20whatever%20notnull%20value%20I%20put%20there.)%20If%20I%20leave%20the%20space%20after%20-Enabled%20null%2C%20I%20get%20%22%3CU%3EUpdate-MgTeamSchedule%20%3A%20%5BUnknownError%5D%20%3A%20%3C%2FU%3E%3CBR%20%2F%3E%3CU%3EAt%20line%3A1%20char%3A1%3C%2FU%3E%3CBR%20%2F%3E%3CU%3E%2B%20Update-MgTeamSchedule%20-TeamId%20e532aa85-3ec5-4318-9515-6c60cfaa7f36%20-E%20...%3C%2FU%3E%3CBR%20%2F%3E%3CU%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3C%2FU%3E%3CBR%20%2F%3E%3CU%3E%2B%20CategoryInfo%20%3A%20InvalidOperation%3A%20(%7B%20TeamId%20%3D%20e532...GraphSchedule%20%7D%3A%26lt%3B%26gt%3Bf__AnonymousType0%602)%20%5BUpdate-MgTeamSchedule_UpdateExpanded%5D%2C%20Exception%3C%2FU%3E%3CBR%20%2F%3E%3CU%3E%2B%20FullyQualifiedErrorId%20%3A%20UnknownError%2CMicrosoft.Graph.PowerShell.Cmdlets.UpdateMgTeamSchedule_UpdateExpanded%3C%2FU%3E%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAND%20-%20how%20should%20the%20TimeZone%20be%20formatted%20for%20New%20York%3F%20%22American%2FNewYork%22%20or%20%22American%2FNew%20York%22%20(with%20or%20without%20a%20space).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20would%20be%20greatly%20appreciated.%20%3A)%3C%2Fimg%3E%20%3A)%3C%2Fimg%3E%20(I%20am%20not%20a%20PS%20pro%20obviously%2C%20but%20I%20am%20a%20super%20enthusiast.)%20TIA!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Efunction%20EnableShifts%20%7B%0A%20%20param%20(%0A%20%0A%20%0A%20%5Bparameter(%0A%20%20HelpMessage%20%3D%20%22Group%20ID%22%0A%20)%5D%0A%20%5Bstring%5D%20%24tGroupId%0A)%0A%20%20%20%20process%0A%20%20%20%20%7B%0A%23Import-Module%20-Name%20MicrosoftTeams%20%0AConnect-MicrosoftTeams%20-Credential%20%24cred%0A%23%20Let's%20make%20sure%20it's%20getting%20the%20ID%20%0AWrite-Host%20%22Group%20ID%3A%22%20%24tGroupId%0A%0A%26lt%3B%23%20company%2Fapp%20info%20%23%26gt%3B%0A%24AppId%20%3D%20%22xx%22%20%0A%24AppSecret%20%3D%20'xx'%0A%24TenantId%20%3D%20%22xx%22%20%0A%23%24TenantName%20%3D%20%22xx%22%20%0A%23%24TenantShortName%20%3D%20%22xx%22%0A%0A%23%20Construct%20URI%20and%20body%20needed%20for%20authentication%0A%24uri%20%3D%20%22https%3A%2F%2Flogin.microsoftonline.com%2F%24TenantId%2Foauth2%2Fv2.0%2Ftoken%22%0A%0A%24body%20%3D%20%40%7B%0A%20client_id%20%20%20%20%20%3D%20%24AppId%0A%20scope%20%20%20%20%20%20%20%20%20%3D%20%22https%3A%2F%2Fgraph.microsoft.com%2F.default%22%0A%20client_secret%20%3D%20%24AppSecret%0A%20grant_type%20%20%20%20%3D%20%22client_credentials%22%0A%7D%0A%23%20Get%20OAuth%202.0%20Token%0A%24tokenRequest%20%3D%20Invoke-WebRequest%20-Method%20Post%20-Uri%20%24uri%20-ContentType%20%22application%2Fx-www-form-urlencoded%22%20-Body%20%24body%20-UseBasicParsing%0A%23%20Unpack%20Access%20Token%0A%24token%20%3D%20(%24tokenRequest.Content%20%7C%20ConvertFrom-Json).access_token%0A%24headers%20%3D%20%40%7BAuthorization%20%3D%20%22Bearer%20%24token%22%20%7D%0A%24ctype%20%3D%20%22application%2Fjson%22%0A%23%20check%20out%20the%20Team%20output%0AGet-Team%20-GroupId%20%24tGroupId%0A%24uriPath%20%3D%20%22https%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fteams%2F%24tGroupId%22%0A%23%20Connect%20to%20graph%20to%20use%20the%20graph%20powershell%20modules%0AConnect-Graph%20-Scopes%20Schedule.ReadWrite.All%20-TenantId%20%24TenantId%0A%20%20%0A%20%20try%0A%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20see%20what%20this%20command%20returns%0A%20%20%20%20%20%20%20%20%20%20%20%20Get-MgTeamSchedule%20-TeamId%20%24tGroupId%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20THIS%20IS%20WHERE%20I'M%20STUCK%20%23%20%0A%20%20%20%20%20%20%20%20%20%20%20%20Update-MgTeamSchedule%20-TeamId%20%24tGroupId%20-Enabled%20%24true%0A%20%20%20%20%20%23Invoke-WebRequest%20-Method%20Put%20-Uri%20%22%24uriPath%2Fschedule%22%20-ContentType%20%24ctype%20-Headers%20%24headers%20%23%20%7C%20ConvertTo-Json%0A%20%20%20Write-Host%20%22Shifts%20provisioned%22%0A%20%20%7D%0A%20%20catch%0A%20%20%7B%0A%20%20%20Write-Host%20%22Error%20provisioning%20Shifts%3A%22%20%24Error%20-BackgroundColor%20yellow%20-ForegroundColor%20black%0A%20%20%20break%0A%20%20%7D%20%20%20%0A%20%20finally%0A%20%20%7B%0A%20%20%0A%20%20%7D%0A%20%20%20%20%7D%0A%7D%0A%23for%20testing.%20comment%20out%20to%20use%20the%20CreateTeams_Search.CSV%0AEnableShifts%20-tGroupId%20%22xxx%22%20%23Team%20id%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1506392%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EGraph%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EShifts%20in%20Microsoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1512199%22%20slang%3D%22en-US%22%3ERe%3A%20Provisioning%20Shifts%20(schedule)%20for%20a%20Microsoft%20Team%20via%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1512199%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F492885%22%20target%3D%22_blank%22%3E%40LauraFW%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eyou%20are%20getting%20error%20while%20excuting%26nbsp%3B%3CU%3EUpdate-MgTeamSchedule%3CSPAN%3E%26nbsp%3Bcommand.%3C%2FSPAN%3E%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%3CU%3E%3CSPAN%3Etry%20to%20run%20the%20below%20command%20share%20the%20update%20if%20it%20wont%20works.%3C%2FSPAN%3E%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%3CU%3E%3CSPAN%3EUpdate-MgTeamSchedule%20-TeamId%20%24tGroupId%20-Enabled%20%24null%3C%2FSPAN%3E%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CU%3E%3CSPAN%3Eand%20setting%20for%20time%20zone%20please%20go%20through%20below%20links.%3C%2FSPAN%3E%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%3CU%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftahoeninjas.blog%2F2019%2F04%2F25%2Fsetting-the-default-timezone-for-sharepoint-online%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Ftahoeninjas.blog%2F2019%2F04%2F25%2Fsetting-the-default-timezone-for-sharepoint-online%2F%3C%2FA%3E%3C%2FSPAN%3E%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%3CU%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F264997%2Fsharepoint-online-powershell-script-timezone-issue%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F264997%2Fsharepoint-online-powershell-script-timezone-issue%3C%2FA%3E%3C%2FSPAN%3E%3C%2FU%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1518740%22%20slang%3D%22en-US%22%3ERe%3A%20Provisioning%20Shifts%20(schedule)%20for%20a%20Microsoft%20Team%20via%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1518740%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F635527%22%20target%3D%22_blank%22%3E%40teams1535%3C%2FA%3E%26nbsp%3BI%20tried%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EUpdate-MgTeamSchedule%20-TeamId%20%24tGroupId%20-Enabled%20%24null%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EError%20provisioning%20Shifts%3A%20A%20positional%20parameter%20cannot%20be%20found%20that%20accepts%20argument%20'%24null'.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20see%20a%20-BodyParameter%20in%20the%20list%20of%20available%20parameters.%20Can%20I%20use%20that%20somehow%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1528224%22%20slang%3D%22en-US%22%3ERe%3A%20Provisioning%20Shifts%20(schedule)%20for%20a%20Microsoft%20Team%20via%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1528224%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F492885%22%20target%3D%22_blank%22%3E%40LauraFW%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Ecurrently%20below%204%20methods%20are%20available%20to%20do%26nbsp%3B%3CU%3EUpdate-MgTeamSchedule.%20Currently%20MS%20doc%20is%20not%20available%20in%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fmicrosoft.graph.teams.team%2Fupdate-mgteamschedule%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Elink.%3C%2FA%3E%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%3CU%3EPlease%20follow%20that%20link%20for%20the%20latest%20information.%20through%20powershell%20you%20will%20get%20more%20information%20(help%20update-mgteamschedule)command.%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUpdate-MgTeamSchedule%20-TeamId%20%3CSTRING%3E%20%5B-Enabled%5D%20%5B-Id%20%3CSTRING%3E%5D%20%5B-OfferShiftRequests%3CBR%20%2F%3E%3CIMICROSOFTGRAPHOFFERSHIFTREQUEST%3E%5D%20%5B-OfferShiftRequestsEnabled%5D%20%5B-OpenShiftChangeRequests%3CBR%20%2F%3E%3CIMICROSOFTGRAPHOPENSHIFTCHANGEREQUEST%3E%5D%20%5B-OpenShifts%20%3CIMICROSOFTGRAPHOPENSHIFT%3E%5D%20%5B-OpenShiftsEnabled%5D%3CBR%20%2F%3E%5B-ProvisionStatus%20%3CSTRING%3E%5D%20%5B-ProvisionStatusCode%20%3CSTRING%3E%5D%20%5B-SchedulingGroups%20%3CIMICROSOFTGRAPHSCHEDULINGGROUP%3E%5D%3CBR%20%2F%3E%5B-Shifts%20%3CIMICROSOFTGRAPHSHIFT%3E%5D%20%5B-SwapShiftsChangeRequests%20%3CIMICROSOFTGRAPHSWAPSHIFTSCHANGEREQUEST%3E%5D%3CBR%20%2F%3E%5B-SwapShiftsRequestsEnabled%5D%20%5B-TimeClockEnabled%5D%20%5B-TimeOffReasons%20%3CIMICROSOFTGRAPHTIMEOFFREASON%3E%5D%3CBR%20%2F%3E%5B-TimeOffRequests%20%3CIMICROSOFTGRAPHTIMEOFFREQUEST%3E%5D%20%5B-TimeOffRequestsEnabled%5D%20%5B-TimeZone%20%3CSTRING%3E%5D%20%5B-TimesOff%3CBR%20%2F%3E%3CIMICROSOFTGRAPHTIMEOFF%3E%5D%20%5B-WorkforceIntegrationIds%20%3CSTRING%3E%5D%20%5B-Break%5D%20%5B-HttpPipelineAppend%20%3CSENDASYNCSTEP%3E%5D%3CBR%20%2F%3E%5B-HttpPipelinePrepend%20%3CSENDASYNCSTEP%3E%5D%20%5B-PassThru%5D%20%5B-Proxy%20%3CURI%3E%5D%20%5B-ProxyCredential%20%3CPSCREDENTIAL%3E%5D%3CBR%20%2F%3E%5B-ProxyUseDefaultCredentials%5D%20%5B-WhatIf%5D%20%5B-Confirm%5D%20%5B%3CCOMMONPARAMETERS%3E%5D%3C%2FCOMMONPARAMETERS%3E%3C%2FPSCREDENTIAL%3E%3C%2FURI%3E%3C%2FSENDASYNCSTEP%3E%3C%2FSENDASYNCSTEP%3E%3C%2FSTRING%3E%3C%2FIMICROSOFTGRAPHTIMEOFF%3E%3C%2FSTRING%3E%3C%2FIMICROSOFTGRAPHTIMEOFFREQUEST%3E%3C%2FIMICROSOFTGRAPHTIMEOFFREASON%3E%3C%2FIMICROSOFTGRAPHSWAPSHIFTSCHANGEREQUEST%3E%3C%2FIMICROSOFTGRAPHSHIFT%3E%3C%2FIMICROSOFTGRAPHSCHEDULINGGROUP%3E%3C%2FSTRING%3E%3C%2FSTRING%3E%3C%2FIMICROSOFTGRAPHOPENSHIFT%3E%3C%2FIMICROSOFTGRAPHOPENSHIFTCHANGEREQUEST%3E%3C%2FIMICROSOFTGRAPHOFFERSHIFTREQUEST%3E%3C%2FSTRING%3E%3C%2FSTRING%3E%3C%2FP%3E%0A%3CP%3EUpdate-MgTeamSchedule%20-TeamId%20%3CSTRING%3E%20-BodyParameter%20%3CIMICROSOFTGRAPHSCHEDULE%3E%20%5B-Break%5D%20%5B-HttpPipelineAppend%3CBR%20%2F%3E%3CSENDASYNCSTEP%3E%5D%20%5B-HttpPipelinePrepend%20%3CSENDASYNCSTEP%3E%5D%20%5B-PassThru%5D%20%5B-Proxy%20%3CURI%3E%5D%20%5B-ProxyCredential%3CBR%20%2F%3E%3CPSCREDENTIAL%3E%5D%20%5B-ProxyUseDefaultCredentials%5D%20%5B-WhatIf%5D%20%5B-Confirm%5D%20%5B%3CCOMMONPARAMETERS%3E%5D%3C%2FCOMMONPARAMETERS%3E%3C%2FPSCREDENTIAL%3E%3C%2FURI%3E%3C%2FSENDASYNCSTEP%3E%3C%2FSENDASYNCSTEP%3E%3C%2FIMICROSOFTGRAPHSCHEDULE%3E%3C%2FSTRING%3E%3C%2FP%3E%0A%3CP%3EUpdate-MgTeamSchedule%20-InputObject%20%3CITEAMSTEAMIDENTITY%3E%20%5B-Enabled%5D%20%5B-Id%20%3CSTRING%3E%5D%20%5B-OfferShiftRequests%3CBR%20%2F%3E%3CIMICROSOFTGRAPHOFFERSHIFTREQUEST%3E%5D%20%5B-OfferShiftRequestsEnabled%5D%20%5B-OpenShiftChangeRequests%3CBR%20%2F%3E%3CIMICROSOFTGRAPHOPENSHIFTCHANGEREQUEST%3E%5D%20%5B-OpenShifts%20%3CIMICROSOFTGRAPHOPENSHIFT%3E%5D%20%5B-OpenShiftsEnabled%5D%3CBR%20%2F%3E%5B-ProvisionStatus%20%3CSTRING%3E%5D%20%5B-ProvisionStatusCode%20%3CSTRING%3E%5D%20%5B-SchedulingGroups%20%3CIMICROSOFTGRAPHSCHEDULINGGROUP%3E%5D%3CBR%20%2F%3E%5B-Shifts%20%3CIMICROSOFTGRAPHSHIFT%3E%5D%20%5B-SwapShiftsChangeRequests%20%3CIMICROSOFTGRAPHSWAPSHIFTSCHANGEREQUEST%3E%5D%3CBR%20%2F%3E%5B-SwapShiftsRequestsEnabled%5D%20%5B-TimeClockEnabled%5D%20%5B-TimeOffReasons%20%3CIMICROSOFTGRAPHTIMEOFFREASON%3E%5D%3CBR%20%2F%3E%5B-TimeOffRequests%20%3CIMICROSOFTGRAPHTIMEOFFREQUEST%3E%5D%20%5B-TimeOffRequestsEnabled%5D%20%5B-TimeZone%20%3CSTRING%3E%5D%20%5B-TimesOff%3CBR%20%2F%3E%3CIMICROSOFTGRAPHTIMEOFF%3E%5D%20%5B-WorkforceIntegrationIds%20%3CSTRING%3E%5D%20%5B-Break%5D%20%5B-HttpPipelineAppend%20%3CSENDASYNCSTEP%3E%5D%3CBR%20%2F%3E%5B-HttpPipelinePrepend%20%3CSENDASYNCSTEP%3E%5D%20%5B-PassThru%5D%20%5B-Proxy%20%3CURI%3E%5D%20%5B-ProxyCredential%20%3CPSCREDENTIAL%3E%5D%3CBR%20%2F%3E%5B-ProxyUseDefaultCredentials%5D%20%5B-WhatIf%5D%20%5B-Confirm%5D%20%5B%3CCOMMONPARAMETERS%3E%5D%3C%2FCOMMONPARAMETERS%3E%3C%2FPSCREDENTIAL%3E%3C%2FURI%3E%3C%2FSENDASYNCSTEP%3E%3C%2FSENDASYNCSTEP%3E%3C%2FSTRING%3E%3C%2FIMICROSOFTGRAPHTIMEOFF%3E%3C%2FSTRING%3E%3C%2FIMICROSOFTGRAPHTIMEOFFREQUEST%3E%3C%2FIMICROSOFTGRAPHTIMEOFFREASON%3E%3C%2FIMICROSOFTGRAPHSWAPSHIFTSCHANGEREQUEST%3E%3C%2FIMICROSOFTGRAPHSHIFT%3E%3C%2FIMICROSOFTGRAPHSCHEDULINGGROUP%3E%3C%2FSTRING%3E%3C%2FSTRING%3E%3C%2FIMICROSOFTGRAPHOPENSHIFT%3E%3C%2FIMICROSOFTGRAPHOPENSHIFTCHANGEREQUEST%3E%3C%2FIMICROSOFTGRAPHOFFERSHIFTREQUEST%3E%3C%2FSTRING%3E%3C%2FITEAMSTEAMIDENTITY%3E%3C%2FP%3E%0A%3CP%3EUpdate-MgTeamSchedule%20-InputObject%20%3CITEAMSTEAMIDENTITY%3E%20-BodyParameter%20%3CIMICROSOFTGRAPHSCHEDULE%3E%20%5B-Break%5D%3CBR%20%2F%3E%5B-HttpPipelineAppend%20%3CSENDASYNCSTEP%3E%5D%20%5B-HttpPipelinePrepend%20%3CSENDASYNCSTEP%3E%5D%20%5B-PassThru%5D%20%5B-Proxy%20%3CURI%3E%5D%3CBR%20%2F%3E%5B-ProxyCredential%20%3CPSCREDENTIAL%3E%5D%20%5B-ProxyUseDefaultCredentials%5D%20%5B-WhatIf%5D%20%5B-Confirm%5D%20%5B%3CCOMMONPARAMETERS%3E%5D%3C%2FCOMMONPARAMETERS%3E%3C%2FPSCREDENTIAL%3E%3C%2FURI%3E%3C%2FSENDASYNCSTEP%3E%3C%2FSENDASYNCSTEP%3E%3C%2FIMICROSOFTGRAPHSCHEDULE%3E%3C%2FITEAMSTEAMIDENTITY%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi :) I am trying to provision Shifts (schedule) for Teams. The overall script creates a new Team, then passes the ID to the shifts piece. But I cannot, for the life of me, find a way to provision it. Here's my code (using a hard coded ID till I figure out what's up.)

 

Ultimately, this will be part of a script that creates several Teams, each needing to have Shifts enabled.

 

Where I start # THIS IS WHERE I'M STUCK # in my code, trying to work with the "Enabled" parameter, I have tried to use $true, 1, nothing, "yes". Nothing works. If I don't leave the space null after -Enabled, I get an error "Update-MgTeamSchedule : A positional parameter cannot be found that accepts argument 'True'" (or whatever notnull value I put there.) If I leave the space after -Enabled null, I get "Update-MgTeamSchedule : [UnknownError] :
At line:1 char:1
+ Update-MgTeamSchedule -TeamId e532aa85-3ec5-4318-9515-6c60cfaa7f36 -E ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ({ TeamId = e532...GraphSchedule }:<>f__AnonymousType0`2) [Update-MgTeamSchedule_UpdateExpanded], Exception
+ FullyQualifiedErrorId : UnknownError,Microsoft.Graph.PowerShell.Cmdlets.UpdateMgTeamSchedule_UpdateExpanded"

 

AND - how should the TimeZone be formatted for New York? "American/NewYork" or "American/New York" (with or without a space).

 

Any help would be greatly appreciated. :) :) (I am not a PS pro obviously, but I am a super enthusiast.) TIA!

 

function EnableShifts {
  param (
	
	
	[parameter(
		HelpMessage = "Group ID"
	)]
	[string] $tGroupId
)
    process
    {
#Import-Module -Name MicrosoftTeams	
Connect-MicrosoftTeams -Credential $cred
# Let's make sure it's getting the ID	
Write-Host "Group ID:" $tGroupId

<# company/app info #>
$AppId = "xx" 
$AppSecret = 'xx'
$TenantId = "xx" 
#$TenantName = "xx" 
#$TenantShortName = "xx"

# Construct URI and body needed for authentication
$uri = "https://login.microsoftonline.com/$TenantId/oauth2/v2.0/token"

$body = @{
	client_id     = $AppId
	scope         = "https://graph.microsoft.com/.default"
	client_secret = $AppSecret
	grant_type    = "client_credentials"
}
# Get OAuth 2.0 Token
$tokenRequest = Invoke-WebRequest -Method Post -Uri $uri -ContentType "application/x-www-form-urlencoded" -Body $body -UseBasicParsing
# Unpack Access Token
$token = ($tokenRequest.Content | ConvertFrom-Json).access_token
$headers = @{Authorization = "Bearer $token" }
$ctype = "application/json"
# check out the Team output
Get-Team -GroupId $tGroupId
$uriPath = "https://graph.microsoft.com/v1.0/teams/$tGroupId"
# Connect to graph to use the graph powershell modules
Connect-Graph -Scopes Schedule.ReadWrite.All -TenantId $TenantId
		
		try
		{
            # see what this command returns
            Get-MgTeamSchedule -TeamId $tGroupId
            # THIS IS WHERE I'M STUCK # 
            Update-MgTeamSchedule -TeamId $tGroupId -Enabled $true
	    #Invoke-WebRequest -Method Put -Uri "$uriPath/schedule" -ContentType $ctype -Headers $headers # | ConvertTo-Json
	  Write-Host "Shifts provisioned"
		}
		catch
		{
			Write-Host "Error provisioning Shifts:" $Error -BackgroundColor yellow -ForegroundColor black
			break
		}   
		finally
		{
		
		}
    }
}
#for testing. comment out to use the CreateTeams_Search.CSV
EnableShifts -tGroupId "xxx" #Team id

 

 

3 Replies
Highlighted

Hi @LauraFW 

 

you are getting error while excuting Update-MgTeamSchedule command.

try to run the below command share the update if it wont works.

Update-MgTeamSchedule -TeamId $tGroupId -Enabled $null

 

and setting for time zone please go through below links.

https://tahoeninjas.blog/2019/04/25/setting-the-default-timezone-for-sharepoint-online/

https://sharepoint.stackexchange.com/questions/264997/sharepoint-online-powershell-script-timezone-i...

Highlighted

@teams1535 I tried

Update-MgTeamSchedule -TeamId $tGroupId -Enabled $null

 

Error provisioning Shifts: A positional parameter cannot be found that accepts argument '$null'.

 

I see a -BodyParameter in the list of available parameters. Can I use that somehow?

Highlighted

Hi@LauraFW 

 

currently below 4 methods are available to do Update-MgTeamSchedule. Currently MS doc is not available in the link.

Please follow that link for the latest information. through powershell you will get more information (help update-mgteamschedule)command.

 

Update-MgTeamSchedule -TeamId <String> [-Enabled] [-Id <String>] [-OfferShiftRequests
<IMicrosoftGraphOfferShiftRequest[]>] [-OfferShiftRequestsEnabled] [-OpenShiftChangeRequests
<IMicrosoftGraphOpenShiftChangeRequest[]>] [-OpenShifts <IMicrosoftGraphOpenShift[]>] [-OpenShiftsEnabled]
[-ProvisionStatus <String>] [-ProvisionStatusCode <String>] [-SchedulingGroups <IMicrosoftGraphSchedulingGroup[]>]
[-Shifts <IMicrosoftGraphShift[]>] [-SwapShiftsChangeRequests <IMicrosoftGraphSwapShiftsChangeRequest[]>]
[-SwapShiftsRequestsEnabled] [-TimeClockEnabled] [-TimeOffReasons <IMicrosoftGraphTimeOffReason[]>]
[-TimeOffRequests <IMicrosoftGraphTimeOffRequest[]>] [-TimeOffRequestsEnabled] [-TimeZone <String>] [-TimesOff
<IMicrosoftGraphTimeOff[]>] [-WorkforceIntegrationIds <String[]>] [-Break] [-HttpPipelineAppend <SendAsyncStep[]>]
[-HttpPipelinePrepend <SendAsyncStep[]>] [-PassThru] [-Proxy <Uri>] [-ProxyCredential <PSCredential>]
[-ProxyUseDefaultCredentials] [-WhatIf] [-Confirm] [<CommonParameters>]

Update-MgTeamSchedule -TeamId <String> -BodyParameter <IMicrosoftGraphSchedule> [-Break] [-HttpPipelineAppend
<SendAsyncStep[]>] [-HttpPipelinePrepend <SendAsyncStep[]>] [-PassThru] [-Proxy <Uri>] [-ProxyCredential
<PSCredential>] [-ProxyUseDefaultCredentials] [-WhatIf] [-Confirm] [<CommonParameters>]

Update-MgTeamSchedule -InputObject <ITeamsTeamIdentity> [-Enabled] [-Id <String>] [-OfferShiftRequests
<IMicrosoftGraphOfferShiftRequest[]>] [-OfferShiftRequestsEnabled] [-OpenShiftChangeRequests
<IMicrosoftGraphOpenShiftChangeRequest[]>] [-OpenShifts <IMicrosoftGraphOpenShift[]>] [-OpenShiftsEnabled]
[-ProvisionStatus <String>] [-ProvisionStatusCode <String>] [-SchedulingGroups <IMicrosoftGraphSchedulingGroup[]>]
[-Shifts <IMicrosoftGraphShift[]>] [-SwapShiftsChangeRequests <IMicrosoftGraphSwapShiftsChangeRequest[]>]
[-SwapShiftsRequestsEnabled] [-TimeClockEnabled] [-TimeOffReasons <IMicrosoftGraphTimeOffReason[]>]
[-TimeOffRequests <IMicrosoftGraphTimeOffRequest[]>] [-TimeOffRequestsEnabled] [-TimeZone <String>] [-TimesOff
<IMicrosoftGraphTimeOff[]>] [-WorkforceIntegrationIds <String[]>] [-Break] [-HttpPipelineAppend <SendAsyncStep[]>]
[-HttpPipelinePrepend <SendAsyncStep[]>] [-PassThru] [-Proxy <Uri>] [-ProxyCredential <PSCredential>]
[-ProxyUseDefaultCredentials] [-WhatIf] [-Confirm] [<CommonParameters>]

Update-MgTeamSchedule -InputObject <ITeamsTeamIdentity> -BodyParameter <IMicrosoftGraphSchedule> [-Break]
[-HttpPipelineAppend <SendAsyncStep[]>] [-HttpPipelinePrepend <SendAsyncStep[]>] [-PassThru] [-Proxy <Uri>]
[-ProxyCredential <PSCredential>] [-ProxyUseDefaultCredentials] [-WhatIf] [-Confirm] [<CommonParameters>]