FunctionsPublic/Publish-GraphPage.ps1
<#
.SYNOPSIS Publish a SharePoint page to a SharePoint site .DESCRIPTION Publish a specific SharePoint page. Uses the beta API. .PARAMETER accessToken A Microsoft Graph API access token with the required permissions .PARAMETER sharePointSiteID The SharePoint site to which the page should be added .PARAMETER sharePointPageID The SharePoint page which to publish #> function Publish-GraphPage { param( [parameter(Mandatory=$true)][psobject]$accessToken, [parameter(Mandatory=$true)][string]$sharePointSiteID, [parameter(Mandatory=$true)][string]$sharePointPageID ) $responseBody = Invoke-RestMethod ` -Uri "https://graph.microsoft.com/beta/sites/$($sharePointSiteID)/pages/$($sharePointPageID)/publish" ` -Headers @{"Authorization" = "Bearer $($accessToken.AccessTokenCredential.GetNetworkCredential().password)"} ` -ContentType "application/json" ` -Method POST if($null -eq $responseBody) { return $null } else { return $responseBody.value } } |