关闭组织的 Planner 中的 Outlook 日历同步

注意: 我们希望能够尽快以你的语言为你提供最新的帮助内容。本页面是自动翻译的,可能包含语法错误或不准确之处。我们的目的是使此内容能对你有所帮助。可以在本页面底部告诉我们此信息是否对你有帮助吗?请在此处查看本文的英文版本以便参考。

如果你是 Office 365 的全局管理员, 并且想要在Microsoft Planner中关闭日历同步, 则可以使用Windows PowerShell。对于将Planner作为其 Office 365 订阅的一部分的所有组织, Planner 将自动打开。

在Windows PowerShell中进行Planner更改的先决条件

此过程将引导你完成在PowerShell中下载运行Planner管理命令所需的文件:

  • 两个 Active Directory dll

  • 一个PowerShell脚本

  • 脚本的清单

如果你不熟悉Windows PowerShell, 请参阅使用 Windows PowerShell

  1. 导航到https://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory/2.29.0

  2. 在右侧, 选择 "手动下载", 选择 "另存为", 选择要将其保存到的位置, 然后选择 "保存"。

  3. 在文件资源管理器中查找文件, 并将其文件扩展名从 nupkg 更改为 .zip。

  4. 右键单击文件, 然后选择 "属性"。在 "常规" 选项卡上, 如果看到 "取消阻止" 复选框, 请将其选中, 然后选择"确定"

  5. 右键单击 .zip 文件, 然后选择 "全部提取"。选择 "提取"。最终将获得一个名为 "identitymodel. 2.29.0" 的解压缩文件夹。

  6. 将以下代码复制到文本编辑器中, 并将其另存为 "identitymodel psm1 2.29.0 \ lib\net45" 文件夹中的 SetPlannerTenantSettings。

    function Connect-AAD ()
    {
    <#
    .Synopsis
    (Private to module) Attempts to obtain a token from AAD.
    .Description
    This function attempts to obtain a token from Azure Active Directory.
    .example
    $authorizationContext = Connect-AAD
    #>
        $authUrl = "https://login.microsoftonline.com/common" # Prod environment
        $resource = "https://tasks.office.com" # Prod environment
        $clientId = "d3590ed6-52b3-4102-aeff-aad2292ab01c"
       
        $redirectUri = "urn:ietf:wg:oauth:2.0:oob"
        $promptBehavior = [Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior]::Always
       
        $authentiationContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authUrl, $False
       
        $authenticationResult = $authentiationContext.AcquireToken($resource, $clientId, $redirectUri, $promptBehavior)
        return $authenticationResult
    }
    function Set-PlannerConfiguration
    {
    <#
    .Synopsis
    Configures tenant level settings for Microsoft Planner.
    .Description
    This cmdlet allows tenant administrators to change policies regarding availability of certain features in Microsoft Planner. The changes to settings take effect immediately. This cmdlet specifies the administrator preference on whether the feature should be available. The features can still be disabled due to Microsoft Planner behavior, at the discretion of Microsoft.
    .Parameter Uri
    The URL of the Tenant-Level Settings API for the Planner instance to control.
    .Parameter AccessToken
    A valid access token of a user with tenant-level administrator privileges.
    .Parameter AllowCalendarSharing
    If set to $false, disables creating iCalendar links from Microsoft Planner, and disables previously created iCalendar links.  If set to $true, enables creating iCalendar links from Microsoft Planner and re-enables any previously created iCalendar links.
    .example
    Set-PlannerConfiguration -AllowCalendarSharing $true
    #>
        param(
            [ValidateNotNull()]
            [System.String]$Uri="https://tasks.office.com/taskAPI/tenantAdminSettings/Settings",
            [ValidateNotNullOrEmpty()]
            [Parameter(Mandatory=$false)][System.String]$AccessToken,
            [Parameter(Mandatory=$false, ValueFromPipeline=$true)][System.Boolean]$AllowCalendarSharing
            )
       
        if(!($PSBoundParameters.ContainsKey("AccessToken"))){
            $authorizationContext = Connect-AAD
            $AccessToken = $authorizationContext.AccessTokenType.ToString() + ' ' +$authorizationContext.AccessToken
        }
       
        $flags = @{}
       
        if($PSBoundParameters.ContainsKey("AllowCalendarSharing")){
            $flags.Add("allowCalendarSharing", $AllowCalendarSharing);
        }
        $propertyCount = $flags | Select-Object -ExpandProperty Count
       
        if($propertyCount -eq 0) {
            Throw "No properties were set."
        }
       
        $requestBody = $flags | ConvertTo-Json
        Invoke-RestMethod -ContentType "application/json;odata.metadata=full" -Headers @{"Accept"="application/json"; "Authorization"=$AccessToken; "Accept-Charset"="UTF-8"; "OData-Version"="4.0;NetFx"; "OData-MaxVersion"="4.0;NetFx"} -Method PATCH -Body $requestBody $Uri
    }
    function Get-PlannerConfiguration
    {
    <#
    .Synopsis
    Retrieves tenant level settings for Microsoft Planner.
    .Description
    This cmdlet allows users and tenant administrators to retrieve policy preferences set by the tenant administrator regarding availability of certain features in Microsoft Planner.  While a feature may be permitted by a tenant administrator's preference, features can still be disabled due to Microsoft Planner behavior, at the discretion of Microsoft.
    .Parameter Uri
    The URL of the Tenant-Level Settings API for the Planner instance to retrieve.
    .Parameter AccessToken
    A valid access token of a user with tenant-level administrator privileges.
    .example
    Get-PlannerConfiguration
    #>
        param(
            [ValidateNotNull()]
            [System.String]$Uri="https://tasks.office.com/taskAPI/tenantAdminSettings/Settings",
            [Parameter(Mandatory=$false)]
            [ValidateNotNullOrEmpty()]
            [System.String]$AccessToken
            )
       
        if(!($PSBoundParameters.ContainsKey("AccessToken"))){
            $authorizationContext = Connect-AAD
            $accessToken = $authorizationContext.AccessTokenType.ToString() + ' ' +$authorizationContext.AccessToken
        }
       
        $response = Invoke-RestMethod -ContentType "application/json;odata.metadata=full" -Headers @{"Accept"="application/json"; "Authorization"=$AccessToken; "Accept-Charset"="UTF-8"; "OData-Version"="4.0;NetFx"; "OData-MaxVersion"="4.0;NetFx"} -Method GET $Uri
        $result = New-Object psobject
        $result | Add-Member -NotePropertyName "SettingName" -NotePropertyValue "AllowCalendarSharing"
        $result | Add-Member -NotePropertyName "Value" -NotePropertyValue $response.allowCalendarSharing
        return $result
    }
    Export-ModuleMember -Function Get-PlannerConfiguration, Set-PlannerConfiguration
    
  7. 将以下代码复制到文本编辑器中, 并将其另存为 "identitymodel psd1 2.29.0 \ lib\net45" 文件夹中的 SetPlannerTenantSettings。

    #
    # Module manifest for module 'SetTenantSettings'
    #
    # Generated by: Microsoft Corporation
    #
    # Generated on: 12/17/2017
    #
    
    @{
    
    # Script module or binary module file associated with this manifest.
    RootModule = 'SetPlannerTenantSettings.psm1' 
    # Version number of this module. 
    ModuleVersion = '1.0' 
    # Supported PSEditions # 
    CompatiblePSEditions = @() 
    # ID used to uniquely identify this module 
    GUID = '6250c644-4898-480c-8e0b-bd3ebdf246ca' 
    # Author of this module 
    Author = 'Microsoft Corporation' 
    # Company or vendor of this module 
    CompanyName = 'Microsoft Corporation' 
    # Copyright statement for this module 
    Copyright = '(c) 2017 Microsoft Corporation. All rights reserved.' 
    # Description of the functionality provided by this module 
    Description = 'Planner Tenant Settings client' 
    # Minimum version of the Windows PowerShell engine required by this module #
    PowerShellVersion = '' 
    # Name of the Windows PowerShell host required by this module # 
    PowerShellHostName = '' 
    # Minimum version of the Windows PowerShell host required by this module #
    PowerShellHostVersion = '' 
    # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. #
    DotNetFrameworkVersion = '' 
    # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. # 
    CLRVersion = '' 
    # Processor architecture (None, X86, Amd64) required by this module #
    ProcessorArchitecture = '' 
    # Modules that must be imported into the global environment prior to importing this module # 
    RequiredModules = @() 
    # Assemblies that must be loaded prior to importing this module 
    RequiredAssemblies = @("Microsoft.IdentityModel.Clients.ActiveDirectory.dll","Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll") 
    # Script files (.ps1) that are run in the caller's environment prior to importing this module. # 
    ScriptsToProcess = @() 
    # Type files (.ps1xml) to be loaded when importing this module # 
    TypesToProcess = @() 
    # Format files (.ps1xml) to be loaded when importing this module # 
    FormatsToProcess = @() 
    # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess # 
    NestedModules = @() 
    # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. 
    FunctionsToExport = @("Get-PlannerConfiguration", "Set-PlannerConfiguration") 
    # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. 
    CmdletsToExport = @() 
    # Variables to export from this module 
    VariablesToExport = '*' 
    # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. 
    AliasesToExport = @() 
    # DSC resources to export from this module # 
    DscResourcesToExport = @() 
    # List of all modules packaged with this module # 
    ModuleList = @() 
    # List of all files packaged with this module # 
    FileList = @("SetTenantSettings.psm1") 
    # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. 
    PrivateData = @{ PSData = @{ 
    # Tags applied to this module. These help with module discovery in online galleries. # 
    Tags = @() 
    # A URL to the license for this module. # 
    LicenseUri = '' 
    # A URL to the main website for this project. # 
    ProjectUri = '' 
    # A URL to an icon representing this module. # 
    IconUri = '' 
    # ReleaseNotes of this module # 
    ReleaseNotes = '' } 
    # End of PSData hashtable 
    } 
    # End of PrivateData hashtable 
    # HelpInfo URI of this module # 
    HelpInfoURI = '' 
    # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. # 
    DefaultCommandPrefix = '' }
    
  8. 运行此命令以将这些文件导入到PowerShell, 并确保从计算机添加你的唯一文件路径:

    Import-Module [File path on your computer]microsoft.identitymodel.clients.activedirectory.2.29.0\lib\net45\SetPlannerTenantSettings.psd1 

现在, 您已准备好使用PowerShell在组织级别上对Planner进行更改。

使用PowerShell在Planner中关闭或打开 Outlook 日历同步

  1. 打开PowerShell并运行以下命令以关闭Planner的 Outlook 日历同步:

    Set-PlannerConfiguration -AllowCalendarSharing $false

    要在Planner中重新打开 Outlook 日历同步, 请执行以下操作:

    Set-PlannerConfiguration -AllowCalendarSharing $true

    注意: 你需要使用你的Azure Active Directory凭据登录。

  2. 若要验证设置, 请执行以下操作:

    • 在PowerShell中, 运行: Get-PlannerConfiguration

    • 在Planner中, 转到Planner > "我的任务"。选择省略号 (...)。如果你看到 "将我的任务添加到 Outlook 日历"命令, 并且未启用, 则 Outlook 日历同步处于启用状态。

扩展你的 Office 技能
了解培训
抢先获得新功能
加入 Office 预览体验计划

此信息是否有帮助?

谢谢您的反馈!

谢谢你的反馈! 可能需要转接到 Office 支持专员。

×