How to auto answer using powershell?

Hi everyone,

I’m trying to use commands to copy and apply a template from sharepoint site to another but the problem is that it asks me to overwrite the file every time I execute the commands. How do I automatically say Yes to that question ?

Heres the commands :

Connect-PnPOnline -Url https://XXX.sharepoint.com/sites/test1
Get-PnPSiteTemplate -out template.pnp -Handlers PageContents -IncludeAllClientSidePages -PersistBrandingFiles # asks to overwite
Connect-PnPOnline -Url https://XXX.sharepoint.com/sites/test10
Invoke-PnPSiteTemplate .\template.pnp # asks to overwite

Thanks !

ÜNKNØWÑ,
Welcome to the forum. :wave:t4:

According to the documentation the cmdlet supports the parameter -Force.

Did you try this?

Regardless of that: when you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org <---- Click :point_up_2:t4: :wink:

1 Like