Power Automate删除SharePoint Online或OneDrive for Business文件版本历史

SharePoint Online和OneDrive for Business支持版本控制,可以保留文件的版本历史,方便用户随时查看和恢复以前的版本。但该功能也会占用大量SharePoint Online或OneDrive for Business存储空间。官方删除版本历史的方法无法批量操作,故今天提供一种使用Power Automate来删除SharePoint Online或OneDrive for Business文件版本历史。

第一步:添加“Get files(properties only)”操作,以获取列表中的文件。

第二步:添加“Send an HTTP request to SharePoint”操作:

Method: GET

Uri: _api/web/GetFolderByServerRelativeUrl('Dynamic content of Folder Path')/Files('Dynamic content of File name with extension')/Versions

Power Automate删除SharePoint Online或OneDrive for Business文件版本历史_第1张图片

第三步:“Parse JSON”,将上一个动作的正文放入解析 JSON 动作的内容中,然后点击“使用示例负载”按钮生成 schema 粘贴如下 schema:

{

    "type": "object",

    "properties": {

        "d": {

            "type": "object",

            "properties": {

                "results": {

                    "type": "array",

                    "items": {

                        "type": "object",

                        "properties": {

                            "__metadata": {

                                "type": "object",

                                "properties": {

                                    "id": {

                                        "type": "string"

                                    },

                                    "uri": {

                                        "type": "string"

                                    },

                                    "type": {

                                        "type": "string"

                                    }

                                }

                            },

                            "CreatedBy": {

                                "type": "object",

                                "properties": {

                                    "__deferred": {

                                        "type": "object",

                                        "properties": {

                                            "uri": {

                                                "type": "string"

                                            }

                                        }

                                    }

                                }

                            },

                            "CheckInComment": {

                                "type": "string"

                            },

                            "Created": {

                                "type": "string"

                            },

                            "ID": {

                                "type": "integer"

                            },

                            "IsCurrentVersion": {

                                "type": "boolean"

                            },

                            "Length": {

                                "type": "string"

                            },

                            "Size": {

                                "type": "integer"

                            },

                            "Url": {

                                "type": "string"

                            },

                            "VersionLabel": {

                                "type": "string"

                            }

                        },

                        "required": [

                            "__metadata",

                            "CreatedBy",

                            "CheckInComment",

                            "Created",

                            "ID",

                            "IsCurrentVersion",

                            "Length",

                            "Size",

                            "Url",

                            "VersionLabel"

                        ]

                    }

                }

            }

        }

    }

}

Power Automate删除SharePoint Online或OneDrive for Business文件版本历史_第2张图片

第四步:创建另一个“Send an Http request to SharePoint”:

Method: DELETE

Uri: _api/web/GetFolderByServerRelativeUrl('Dynamic content of Folder Path')/Files('Dynamic content of File name with extension')/Versions(ID from the previous action)

你可能感兴趣的:(现代办公,巨硬生活,Power,Platform,sharepoint,onedrive,microsoft,power,automate,power,platform)