-
Notifications
You must be signed in to change notification settings - Fork 3.3k
PowerShell Script Get-SPOProvisioningTemplate fails if no output file exists #921
Comments
Can you double check you have the appropriate rights to create a file in root of your C: drive (according the example you posted in the issue you try to create a file in the root of your drive). I cannot reproduce the issue, in my case it's always creating file. |
this is strange. I have not changed anything in that part of the cmdlet since the last release. The only thing I can think of is that's an access right issue... |
If I run the equivalent command in C# and visual studio to the same place it works OK. It must have permissions because it deletes the blank file I put in when I use the -Force option before it says file not found. I have tried using different places including my documents library which I certainly have access to. |
The SharePoint Online version works OK. Its the On-Premises version which is not working. I ran both on the same laptop, to the same file location. |
Looking at the Screen shot your calling a script within the PowerShell window by dot sourcing - Have you tried to run PowerShell as Administrator with this? I only ask as on occasions with certain directories you need to be running in the privileged mode to be able to make any changes in that directory - due to UAC |
I have managed to run this successfully on the x64 version of the command. The. x64 online and on-premises works fine. the x86 online version works fine, the x86 on-Premises version does not work. I hope that helps. |
Found the issue ! If I type at the command prompt Get-SPOProvisioningTemplate https://......... -Out C:\Mytemplate it works. If I put Get-SPOProvisioningTemplate etc into a .ps1 file and call . .\mybatchfile.ps1 it fails. Whether it is in an administrator PowerShell windows or just an ordinary one. |
Hi |
try to full uninstall the cmdlets through the Control Panel and reinstall them by first downloading them from https://github.com/officedev/pnp-powershell/releases. I checked the latest build and both the V15 and V16 version install the Newtonsoft.Json dll in the correct folder. |
I get the same experience as NPrice99. I tested the code from the PowerShell Command Get-SPOProvisioningTemplate in separate console project with just C# and OfficeDevPnP.Core, this works. The version (source code and installer package) is downloaded with the GitHub Windows Desktop Tool. I saw a strange behavior: I can select the Schema V201508 in PowerShell, but cannot see where it is in the installed DLLs. |
I solved the issue with the schema, two versions was installed on the system. I attached the debugger and saw that the exception occurs in line 115 of GetProvisiongTemplate.cs, in the method OfficeDevPnP.PowerShell.Commands.Branding.GetProvisioningTemplateXML(XMLPnPSchemaVersion schema, string path), the SelectedWeb property throws the FileNotFoundException. Any ideas? |
Hmm, first I got the innerexception "The Push Notifications feature is not activated on the site 'http://portal.chrpap.com'", so I activated it through Enable-SPFeature -Identity 41e1d4bf-b1a2-47f7-ab80-d5d6cbba3092 -URL "http://portal.chrpap.com". But get another exception from OfficeDevPnP.PowerShell.Commands.WebExtensions.GetWebByUrl() in line 25 (clientContext.ExecuteQueryRetry()). Could it be that it is only possible to get webs from the same site collection? I found it: the problem is the site.OpenWeb(url) method. So in my example I using one site collection for one web, every time. If I connect with the CMDLet Connect-SPOnline to my template site and use for Get-SPOProvisioningTemplate the web parameter with an empty string, then everything works fine. It would be nice the make the URL switch in OfficeDevPnP.Core directly. |
Hi Patrick |
If you type in Get-SPOProvisioningTemplate -Out "C:\MyOutputfile.xml" then the command fails "file not found" if the output file "C:\MyOutputfile.xml" does not already exist.
If you create a blank file "C:\MyOutputfile.xml" and rerun command it now works and asks you if you want to overwrite the existing file.
If you say "Y" it deletes the existing file and then says "File not found" and exits. If you say "no" the command exits.
If you add -Force it fails "File Not found" .
The text was updated successfully, but these errors were encountered: