Hi all,
I work at a school and have a script to create sites, users and folders automatically. In the finaI steps of the script I need to copy a page from a Sharepoint to another and make it the homepage, but I can't and have been stuck...
Here's what I have so far...
$cred = Get-Credential
Connect-PnPOnline -Url https://tenant.sharepoint.com/sites/sitewiththepagemodel -Credentials $cred
$tempFile = [System.IO.Path]::GetTempFileName();
Export-PnPPage -Identity "SitePages/Bem-vindo-ao-site-da-Turma.aspx" -Force -Out $tempFile
Connect-PnPOnline -Url "https://tenant.sharepoint.com/sites/sitebeingcreated" -Credentials $cred
Apply-PnPProvisioningTemplate -Path $tempFile
Set-PnPHomePage -RootFolderRelativeUrl SitePages/Bem-vindo-ao-site-da-Turma.aspx
When run I get the error:
Export-PnPPage : The object reference was not defined as an instance of an object
At line:630 char:1
+ Export-PnPPage -Identity "SitePages/Bem-vindo-ao-site-da-Turma.aspx" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Export-PnPPage], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,PnP.PowerShell.Commands.Provisioning.Tenant.ExportPage
** The part of the error above has been translated
I'm not very good at Powershell so please, be gentle!! ;)
Thanks a lot for your help