powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[BUG] Invoke-PnPSiteTemplate: file not found

Open joelfmrodrigues opened this issue 3 years ago • 1 comments

Reporting an Issue or Missing Feature

Issue I understand that this could potentially be an issue with the core NuGet package and not PnP.PowerShell, but not completely sure as the Path parameter is parsed here. Feel free to transfer if this belongs to the other repo, or I can open a new one there if transferring is not possible

Expected behavior

Be able to apply a site template containing Term Groups, Term Sets and Terms using a relative path to the template file

Actual behavior

When I try to apply a template that contains taxonomy using a relative path, I get the error "file not found". Example: Invoke-PnPSiteTemplate -Path .\Taxonomy.xml

If I then use a full path, it works. Example Invoke-PnPSiteTemplate -Path c:\dev\Taxonomy.xml

Relative path works fine with other templates that do not have the <pnp:TermGroups> element

Steps to reproduce behavior

Create a template file with Term Groups or use the below as example:

<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2020/02/ProvisioningSchema">
  <pnp:Templates ID="CONTAINER-TEMPLATE-E5983A66D6B549EC9883E3D2E13B5508">
    <pnp:ProvisioningTemplate ID="TEMPLATE-E5983A66D6B549EC9883E3D2E13B5508" Version="1" BaseSiteTemplate="SITEPAGEPUBLISHING#0" Scope="RootSite">
      <pnp:TermGroups>
        <pnp:TermGroup Name="TestTermGroup" ID="494db2f0-d41f-45e3-b6a5-1739eee6eb6a" Description="" UpdateBehavior="Overwrite">
          <pnp:TermSets>
            <pnp:TermSet Name="TestTermSet" ID="fba7f47b-2f74-462c-8302-9dacf98d7ea6" Description="">
              <pnp:CustomProperties>
                <pnp:Property Key="_Sys_Nav_IsNavigationTermSet" Value="True" />
              </pnp:CustomProperties>
              <pnp:Terms>
                <pnp:Term Name="SocialLinks" ID="4e2c3cb5-2723-4e5e-aae1-60d2a6d112d9" Description="" CustomSortOrder="3">
                  <pnp:Terms>
                    <pnp:Term Name="Facebook" ID="e136bbaf-7a93-444f-9b51-4bff49fa6004" Description="">
                      <pnp:Terms />
                      <pnp:LocalCustomProperties>
                        <pnp:Property Key="_Sys_Nav_FriendlyUrlSegment" Value="Facebook" />
                        <pnp:Property Key="_Sys_Nav_HoverText" Value="" />
                        <pnp:Property Key="_Sys_Nav_SimpleLinkUrl" Value="https://www.facebook.com/" />
                        <pnp:Property Key="_Sys_Nav_Title" Value="Facebook" />
                        <pnp:Property Key="iconName" Value="facebook" />
                      </pnp:LocalCustomProperties>
                    </pnp:Term>
                    <pnp:Term Name="Twitter" ID="46a318a2-1f00-4ad5-b96a-45e663178857" Description="">
                      <pnp:Terms />
                      <pnp:LocalCustomProperties>
                        <pnp:Property Key="_Sys_Nav_FriendlyUrlSegment" Value="Twitter" />
                        <pnp:Property Key="_Sys_Nav_HoverText" Value="" />
                        <pnp:Property Key="_Sys_Nav_SimpleLinkUrl" Value="https://twitter.com/" />
                        <pnp:Property Key="_Sys_Nav_Title" Value="Twitter" />
                        <pnp:Property Key="iconName" Value="twitter" />
                      </pnp:LocalCustomProperties>
                    </pnp:Term>
                    <pnp:Term Name="YouTube" ID="1486a103-19c8-4b5f-887a-1cf8fdd3aacb" Description="">
                      <pnp:Terms />
                      <pnp:LocalCustomProperties>
                        <pnp:Property Key="_Sys_Nav_FriendlyUrlSegment" Value="YouTube" />
                        <pnp:Property Key="_Sys_Nav_HoverText" Value="" />
                        <pnp:Property Key="_Sys_Nav_SimpleLinkUrl" Value="https://www.youtube.com/" />
                        <pnp:Property Key="_Sys_Nav_Title" Value="YouTube" />
                        <pnp:Property Key="iconName" Value="youtube" />
                      </pnp:LocalCustomProperties>
                    </pnp:Term>
                  </pnp:Terms>
                </pnp:Term>
              </pnp:Terms>
            </pnp:TermSet>
          </pnp:TermSets>
        </pnp:TermGroup>
      </pnp:TermGroups>
    </pnp:ProvisioningTemplate>
  </pnp:Templates>
</pnp:Provisioning>

Open PowerShell on the folder where the template file is located, connect and apply the template to a site Invoke-PnPSiteTemplate -Path .\Taxonomy.xml

What is the version of the Cmdlet module you are running?

1.9.0, but believe it's also present on older versions

Which operating system/environment are you running PnP PowerShell on?

  • [x] Windows
  • [ ] Linux
  • [ ] MacOS
  • [ ] Azure Cloud Shell
  • [ ] Azure Functions
  • [ ] Other : please specify

joelfmrodrigues avatar Jan 28 '22 09:01 joelfmrodrigues

@joelfmrodrigues - can you please try with the latest version ? Tried it right now with 1.11.0 and was not able to reproduce it.

Quite weird though because the code for that hasn't changed for a long time.

gautamdsheth avatar Sep 20 '22 18:09 gautamdsheth

hi @joelfmrodrigues , any update on this please :) Unable to repro now with 1.11 or nightly, am using PS 7.

gautamdsheth avatar Oct 05 '22 19:10 gautamdsheth

@gautamdsheth sorry for the delay, I got the first message and flagged it for testing, but had no chance yet... Will try to test later in the week

joelfmrodrigues avatar Oct 05 '22 20:10 joelfmrodrigues

@gautamdsheth tested again and indeed this works now. Really strange, but hey, it works 🤷‍♂️ Thank you

joelfmrodrigues avatar Oct 07 '22 11:10 joelfmrodrigues