Warm tip: This article is reproduced from serverfault.com, please click

powershell-使用Add-PnPClientSideWebPart添加天气WebPart未设置位置

(powershell - Add weather WebPart using Add-PnPClientSideWebPart is not setting location)

发布于 2020-12-14 04:32:42

我正在尝试在SharePoint Online的现代页面上添加天气WebPart。

这是我正在执行的PowerShell:

$jsonProperties = '
{
    "serverProcessedContent": {
        "searchablePlainTexts": {
            "webPartTitle": "Weather"
        }
    },
    "properties": {
        "temperatureUnit": "C",
        "locations": [
            {
                "countryName": "Australia",
                "name": "Manjimup, Australia",
                "latitude": -34.24055862426758,
                "longitude": 116.14610290527344,
                "showCustomizedDisplayName": false
            },
            {
                "countryName": "Australia",
                "name": "Bega, Australia",
                "latitude": -36.673919677734378,
                "longitude": 149.84178161621095,
                "showCustomizedDisplayName": false
            }
        ]
    }
}'

Add-PnPClientSideWebPart -Page https://mysharepointsite.sharepoint.com/Sites/MyPage -DefaultWebPartType Weather -WebPartProperties $jsonProperties

正在添加WebPart,但是没有天气位置,如下所示。

天气WebPart

要添加到WebPart的位置我缺少什么?

Questioner
Høgsdal
Viewed
0
Høgsdal 2020-12-15 07:18:47

我没有财产了"dataVersion": "1.2"完整的JSON如下所示:

$jsonProperties = '
{
    "dataVersion": "1.2",
    "serverProcessedContent": {
        "searchablePlainTexts": {
            "webPartTitle": "Weather"
        }
    },
    "properties": {
        "temperatureUnit": "C",
        "locations": [
            {
                "countryName": "Australia",
                "name": "Manjimup, Australia",
                "latitude": -34.24055862426758,
                "longitude": 116.14610290527344,
                "showCustomizedDisplayName": false
            },
            {
                "countryName": "Australia",
                "name": "Bega, Australia",
                "latitude": -36.673919677734378,
                "longitude": 149.84178161621095,
                "showCustomizedDisplayName": false
            }
        ]
    }
}'