powershell
powershell copied to clipboard
[BUG] Export-PnPPage does not accept Identities with whitespaces
Reporting an Issue or Missing Feature
I want to export a page with Export-PnPPage but get an error while exporting pages with whitespaces.
Expected behavior
I expect to export a page with whitespaces within the name.
Actual behavior
The PowerShell throws an error
Export-PnPPage: Object reference not set to an instance of an object.
The page name is "Page with whitespace.aspx". Even if I replace the whitespaces with "%20" the export is not working.
Steps to reproduce behavior
Connect-PnPOnline -Url [URL] -Interactive
$TempFile = [System.IO.Path]::GetTempFileName()
Export-PnPPage -Force -Identity "Page with whitespace.aspx" -Out $TempFile
What is the version of the Cmdlet module you are running?
ModuleType Version PreRelease Name PSEdition ExportedCommands
---------- ------- ---------- ---- --------- ----------------
Manifest 2.9.8 nightly PnP.PowerShell Desk {Add-PnPAdaptiveScopeProperty, Add-PnPEntraIDGroupMember, Add-PnPEntraIDGroup…
Which operating system/environment are you running PnP PowerShell on?
- [x] Windows
- [ ] Linux
- [ ] MacOS
- [ ] Azure Cloud Shell
- [ ] Azure Functions
- [ ] Other : please specify
Could you please try passing -ErrorAction:Stop as additional parameter and then logging more exception details with Get-PnPException | Select-Object * ? It will show where in the code the issue is.
If I try with a similar case I get the template:
The GetTempFileName() case works too:
@zzeroo - was able to reproduce this issue. It is because the page doesn't exist in the site/site collection. Have improved the code to throw a better error message. It will be available in tomorrow's nightly builds as well as the next major version.
Thanks for reporting
Thank you @gautamdsheth!
For the record: This issue was not related to the file name or white spaces as I thought. I mixed my credentials and addressed the wrong sharepoint (faceplam). You're completly right the issue was that the page was not in the site/site collection.
Greate project and excelent support. Cheers