0

I am trying to use Sitecore Remote Powershell following the guide here.

No errors are immediately returned, however, looking in the SPE logs I can see the following logs:

8132 10:43:17 INFO  A request to the remoting service was made from IP 127.0.0.1
8132 10:43:17 WARN  The specified user extranet\Anonymous is not authorized for the remoting service.

The examples that I am following are using a $username and $password param in order to provide credentials, so why is Sitecore treating me as an anonymous user?

Any help is appreciated.

Thanks.

1 Answer 1

0

You will need to allow the user inside the remoting section on the SPE.config file as below.

<configuration xmlns:role="http://www.sitecore.net/xmlconfig/role/">
  <sitecore role:require="Standalone or ContentManagement">
    <powershell>
      <services>
        <remoting enabled="true" requireSecureConnection="false">
            <authorization>
              <add Permission="Allow" IdentityType="Role" Identity="sitecore\PowerShell Extensions Remoting" />      
             <!-- Grant permission to the user to excute powershell scripts-->
              <add Permission="Allow" IdentityType="User" Identity="sitecore\{{UserName}}"  desc="{{UserName}}" />
            </authorization>
        </remoting>
      </services>
    </powershell>
   </sitecore>
</configuration>

On the above configuration, username to allow to execute the remote script is added. You can find more details regarding SPE remoting on my blog.

Once the user is added, you need to create script session with the above user as below.

$session = New-ScriptSession -ConnectionUri "{{CMS_Instance_Url}}" -Username {{Username}} -Password {{Password}}

https://sitecorefoundation.in/2024/06/21/deep-dive-into-sitecore-powershell-remoting-module/

Hope this helps!!!

5
  • I believe the role config is already doing that - however, I did try and add the User role as above but I am seeing the same error. It looks like the request is getting to Sitecore but as an Anonymous user as opposed to the user that I am specifying.
    – djh
    Commented Jun 26 at 10:15
  • @djh Can you check the script session is getting created through the command mentioned above.
    – ckhanna
    Commented Jun 26 at 10:28
  • I don't get any feedback when running the New-ScriptSession cmd, even with the -Verbose flag. Only when I then try to execute Invoke-RemoteScript and pass in that session do I see the SPE Logs in regards to anon access.
    – djh
    Commented Jun 26 at 10:56
  • @djh in case possible can you share the snippet of the powershell script code you are trying to tun remotely..
    – ckhanna
    Commented Jun 26 at 14:19
  • Import-Module -Name SPE $session = New-ScriptSession -Username USERNAMEWITHACCESS -Password password -ConnectionUri https://sitecoreinstance/ Invoke-RemoteScript -Session $session -ScriptBlock { Get-User -id admin } Stop-ScriptSession -Session $session
    – djh
    Commented Jul 1 at 10:34

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.