3

We are upgrading our Sitecore version from 8.2 to 10.2. At the moment we are having an issue with Sitecore PowerShell Extension (version 6.4) with the below snippet

$uploadDirectory = Join-Path -Path $SitecoreDataFolder -ChildPath "temp"
$importFilePath = Receive-File -Overwrite -Title "Import Data" -Description "Choose a valid CSV file to import." -Path $uploadDirectory -OkButtonName "Next"

When we try to run it we keep getting error below. We're not sure what's wrong with it.

Server Error in '/' Application.
Calling Spe.Client.Applications.UploadFile.PowerShellUploadFileForm.OKClick method through reflection is not allowed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Sitecore.Exceptions.AccessDeniedException: Calling Spe.Client.Applications.UploadFile.PowerShellUploadFileForm.OKClick method through reflection is not allowed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[AccessDeniedException: Calling Spe.Client.Applications.UploadFile.PowerShellUploadFileForm.OKClick method through reflection is not allowed.]
   Sitecore.Reflection.MethodFilter.Filter(MethodInfo method) +1167
   Sitecore.Shell.Framework.Commands.CommandManager.GetMethodCommand(String command) +701
   Sitecore.Web.UI.Sheer.ClientPage.Dispatch(String command) +35
   Sitecore.Web.UI.Sheer.ClientPage.RaiseEvent() +144
   Sitecore.Web.UI.Sheer.ClientPage.OnPreRender(EventArgs e) +806
   System.Web.UI.Control.PreRenderRecursiveInternal() +200
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7479

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4494.0

Regards, Yos

1
  • Replace your screenshots with error text for SEO reasons. Jun 27, 2023 at 7:00

3 Answers 3

3

This issue appears consistent with problems revealed around the release of Security Bulletin SC2023-003-587441.

Can you see if the file Sitecore.Reflection.Filtering.config exists and determine if the SPE events are blacklisted or allowed?

More information in this issue and blog post.

We recently noticed that the SPE upload dialogs were not working properly and therefore we added these on top of what was provided by Sitecore. This should be fixed in the 10.2.2 hotfix.

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:environment="http://www.sitecore.net/xmlconfig/environment/" xmlns:runInContainer="http://www.sitecore.net/xmlconfig/runInContainer/">
  <sitecore role:require="Standalone or ContentManagement">
    <reflection>
      <allowedMethods>
        <descriptor type="Spe.Client.Applications.UploadFile.PowerShellUploadFileForm" methodName="OKClick" assemblyName="Spe" hint="OK"/>
        <descriptor type="Spe.Client.Applications.UploadFile.PowerShellUploadFileForm" methodName="StartUploading" assemblyName="Spe" hint="StartUpload"/>
        <descriptor type="Spe.Client.Applications.UploadFile.PowerShellUploadFileForm" methodName="EndUploading" assemblyName="Spe" hint="EndUpload"/>
      </allowedMethods>
    </reflection>
  </sitecore>
</configuration>
1
  • Thank you so much for this. It's really because of this.
    – Yos
    Jun 28, 2023 at 7:34
0

It looks like a permission issue AccessDeniedException. Here is a ticket related to uploading an item in Sitecore 8.2.

To resolve the issue, make the user a member of the sitecore/Sitecore Client Authoring role:

  1. Switch to the Core database in the Desktop.

  2. Open the Content Editor and navigate to the sitecore/content/Applications/Dialogs/Upload item.

  3. Click the Security tab and grant sitecore/Sitecore Client Authoring role Read access to the opened item.

Hope it helps!

1
  • Thank you so much for your help on this.
    – Yos
    Jun 28, 2023 at 7:45
0

I tried this using the below script for Sitecore 10.2 version and it worked for me. Here is the code I used.

$SitecoreDataFolder = "C:\temp\"

$uploadDirectory = Join-Path -Path $SitecoreDataFolder -ChildPath "upload"
$importFilePath = Receive-File -Overwrite -Title "Import Data" -Description "Choose a valid CSV file to import." -Path $uploadDirectory -OkButtonName "Next"

I was able to see the popup and the file uploaded successfully on the above path.

enter image description here

What you can try is to reinstall your PowerShell package and try it again. Also check if anything related to permission creating this issue? Finally check the logs and mention in the question if it doesn't work.

Update:

Try to run your code under this and check if it resolve your issue.

$admin = [Sitecore.Security.Accounts.User]::FromName("sitecore\some_admin_account", $false)
[Sitecore.Security.Accounts.UserSwitcher]::Enter($admin)

# YOUR CODE HERE

[Sitecore.Security.Accounts.UserSwitcher]::Exit()

Hope this help.

6
  • Thank you but the error only happen when you choose the file and click next
    – Yos
    Jun 27, 2023 at 9:25
  • Yes I did the same and it worked. Jun 27, 2023 at 9:32
  • Did you try with the same script I used above? Like add a static folder path and check. Jun 27, 2023 at 9:33
  • Yes we did and also try reinstall it. But doesn't seem to help
    – Yos
    Jun 27, 2023 at 10:00
  • I updated my answer. Please check if it works for you. Jun 27, 2023 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.