I would like to publish a pagelayout html file with pnp-Powershell. This is a custom html pagelayout which is related to an aspx file. These files are stored in the masterpage gallery.


I found the solution by my self:

# Retrieve the folder structure
    $folder = Get-SPOFolderItem $url

    # Loop through the folder (subfolders and files)
    $folder | foreach {

        # Is it a folder, recursive call CheckInItem

            # Retrieve all the field of the file
            Get-SPOProperty -ClientObject $_ -Property ListItemAllFields

            # If it is and HtmlDesign locked file we need to skip it
            if($_.ListItemAllFields.FieldValues.MetaInfo -match "HtmlDesignLockedFile"){

            } else {
                # Check if the file needs to be checked out
                if($_.CheckOutType -eq "None"){
                    Set-SPOFileCheckedOut -Url $_.ServerRelativeUrl

                # update list item to create assocation (aspx) file
                $masterpageGalleryList = Get-SPOList -Identity /_catalogs/masterpage

                    Set-SPOListItem -List $masterpageGalleryList -Identity $_.ListItemAllFields.Id -Values @{}

                # Publish the file
                Set-SPOFileCheckedIn -Url $_.ServerRelativeUrl -CheckinType MajorCheckIn


    } > $null
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.