I ran the following Powershell in Runbook and got an error. If there are any inappropriate parts in the logic, I would appreciate it if you could point them out.
Supplemental When I changed the name to Get-PnPFolderItem instead of Get-PnPProvisioningTemplate and executed it, it worked fine. Therefore, I think that Connect-PnPOnline is able to connect normally.
$TempSiteUrl = Get-AutomationVariable -Name 'SiteTemplateUrl'
$myCred = Get-AutomationPSCredential -Name SharePointConnect
Connect-PnPOnline -Url $TempSiteUrl -Credentials $myCred
Get-PnPProvisioningTemplate -Out template.xml
Error message
Get-PnPProvisioningTemplate : There is currently no connection yet. Use Connect-PnPOnline to connect.
At line:4 char:1
+ Get-PnPProvisioningTemplate -Out template.xml
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-PnPProvisioningTemplate], InvalidOperationException
+ FullyQualifiedErrorId :
System.InvalidOperationException,PnP.PowerShell.Commands.Provisioning.Site.GetProvisioningTemplate
Please try to use Get-PnPSiteTemplate
instead: https://learn.microsoft.com/en-us/powershell/module/sharepoint-pnp/get-pnpsitetemplate?view=sharepoint-ps