Replies: 5 comments
-
Are you using or loading any other modules in the runtime like Az or Graph or some other ? If so, can you please comment them out and try ? |
Beta Was this translation helpful? Give feedback.
-
Hi Gautam, thanks for you reply. requirements.psd1 ==>
profile.ps1 ==> Import-Module Az.Accounts #-RequiredVersion '2.12.2' if ($env:MSI_SECRET) { Kind regards, ad unloading other modules) un-commenting Import-Module Az,Accounts from profile.ps1 has no effect. |
Beta Was this translation helpful? Give feedback.
-
Hello @gautamdsheth are there any new experience values regarding this bug? |
Beta Was this translation helpful? Give feedback.
-
Hello @gautamdsheth unfortunately it still does not work. Is there any update on it? Kind regards, |
Beta Was this translation helpful? Give feedback.
-
@Rabomax - unfortunately can't reproduce this issue at my end. Looks like some other module or the translation function might be causing the issue. This is my requirements.psd1 file, as you can see, I only have PnP PowerShell loaded. My profile.ps1 is totally commented out: Will move it to a discussion now. |
Beta Was this translation helpful? Give feedback.
-
Reporting an Issue or Missing Feature
I'm coding a PowerShell script within an Azure Function App that translates SharePoint pages with the help of the PnP.PowerShell module and Azure Translator
Expected behavior
SharePoint page should be translated after calling Set-PnPPageTextPart -Page $newPage -InstanceId $instanceId -Text $translatedControlText
Actual behavior
Getting an CSOM service exception when calling Set-PnPPageTextPart
Exception :
Type : System.Management.Automation.PSInvalidOperationException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : CSOM service exception
HResult : -2146233087
CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : InvalidOperation
TargetSite :
Name : ProcessRecord
DeclaringType : PnP.PowerShell.Commands.Base.PnPConnectedCmdlet
MemberType : Method
Module : PnP.PowerShell.dll
Message : CSOM service exception
Source : PnP.PowerShell
HResult : -2146233079
StackTrace :
at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPConnectedCmdlet.cs:line 98
at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPSharePointCmdlet.cs:line 120
at System.Management.Automation.Cmdlet.DoProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo : InvalidOperation: (:) [Set-PnPPageTextPart], PSInvalidOperationException
FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.Pages.SetClientSideText
InvocationInfo :
MyCommand : Set-PnPPageTextPart
ScriptLineNumber : 116
OffsetInLine : 9
HistoryId : 1
ScriptName : C:\home\site\wwwroot\OnNewSite\run.ps1
Line : Set-PnPPageTextPart -Page $newPage -InstanceId $textControl.InstanceId -Text $translatedControlText
ScriptStackTrace : at , C:\home\site\wwwroot\OnNewSite\run.ps1: line 116
Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: ERROR: CSOM service exception
Exception :
Type : System.Management.Automation.PSInvalidOperationException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : CSOM service exception
HResult : -2146233087
CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : InvalidOperation
TargetSite :
Name : ProcessRecord
DeclaringType : PnP.PowerShell.Commands.Base.PnPConnectedCmdlet
MemberType : Method
Module : PnP.PowerShell.dll
Message : CSOM service exception
Source : PnP.PowerShell
HResult : -2146233079
StackTrace :
at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPConnectedCmdlet.cs:line 98
at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPSharePointCmdlet.cs:line 120
at System.Management.Automation.Cmdlet.DoProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo : InvalidOperation: (:) [Set-PnPPageTextPart], PSInvalidOperationException
FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.Pages.SetClientSideText
InvocationInfo :
MyCommand : Set-PnPPageTextPart
ScriptLineNumber : 116
OffsetInLine : 9
HistoryId : 1
ScriptName : C:\home\site\wwwroot\OnNewSite\run.ps1
Line : Set-PnPPageTextPart -Page $newPage -InstanceId $textControl.InstanceId -Text $translatedControlText
ScriptStackTrace : at , C:\home\site\wwwroot\OnNewSite\run.ps1: line 116
Exception: CSOM service exception
Stack: at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPConnectedCmdlet.cs:line 98
at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPSharePointCmdlet.cs:line 120
at System.Management.Automation.Cmdlet.DoProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
Steps to reproduce behavior
try {
Connect-PnPOnline -Url $siteURL -Tenant $ten -ClientId $app -CertificateBase64Encoded $certificateBase64Encoded
}
catch {
Write-Host ($Error[0].Exception)
}
$newPage = Get-PnPClientSidePage "$targetLanguage/$pageTitle"
$textControls = $newPage.Controls | Where-Object {$_.Type.Name -eq "PageText"}
Write-Host "After retrieved controls..."
foreach ($textControl in $textControls) {
$comp = Get-PnPPageComponent -Page $newPage -InstanceId $textControl.InstanceId
$translatedControlText = Start-Translation -text $comp.Text -language $targetLanguage
Write-Host $translatedControlText
Set-PnPPageTextPart -Page $newPage -InstanceId $textControl.InstanceId -Text $translatedControlText
}
What is the version of the Cmdlet module you are running?
Which operating system/environment are you running PnP PowerShell on?
Additional context
Everything works fine, from establishing the connection with Connect-PnPOnline to retrieving the text webparts of the given page but it always fails on Set-PnPPageTextPart. I have also followed #2795 and updated PnP.PowerShell from 1.12 to 2.1.1 but it also did not work.
Beta Was this translation helpful? Give feedback.
All reactions