Thursday, 27 June 2024

Sitecore remote PSE error "The current user does not have write access to this item"

 Error:

Encountering a 'current user does not have write access to this item' error in Sitecore's PowerShell Extensions (SPE) can be a stumbling block when working remotely.
This error typically indicates that the user account being used for the remote session does not have the necessary permissions to modify the item.




Resolution:  

Grant Appropriate Rights: To resolve this, ensure that the user has been granted the appropriate rights through a configuration patch, as detailed in the SPE documentation. Also, check the remoting service enabled and the user account granted access to the necessary role, it is best to assign the role(sitecore\PowerShell Extensions Remoting)

Check Execution Policy: Confirm that the execution policy is set to RemoteSigned. This allows the SPE Remoting module to run, but it usually requires elevated privileges.

Fallback Option: If the above steps don’t resolve the issue, consider writing your script in SecurityDisabler mode. This will elevate the remote user’s privileges, granting read/write access to Sitecore content items remotely using PSE.

 Here’s an example PowerShell script snippet for reference:

Set-ExecutionPolicy RemoteSigned
Import-Module -Name SPE
$session = New-ScriptSession -Username remoteuser -Password b -ConnectionUri https://CM_instance_URL
Invoke-RemoteScript -ScriptBlock {
New-UsingBlock(New-Object Sitecore.SecurityModel.SecurityDisabler){
New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) {
$item = Get-Item -Path "master:/sitecore/content/Home/test-page"
$item.Editing.BeginEdit()
$item["Title"] = "New Title - I am testing"
$item.Editing.EndEdit()
  }
 }
} -Session $session


Remember to replace placeholders like remoteuserb, and https://CM_instance_URL with actual values relevant to your environment.
Let me know if you need further assistance! 😊