1

I have reviewed the GitBook and the two blog articles (original and v2) about remoting with SPE, but I've not been successful in executing any commands.

Here's an example script I've been trying to get to work:

$session = New-ScriptSession -Username admin -Password b -ConnectionUri http://local.sitecore
Invoke-RemoteScript -Session $session -ScriptBlock { Get-Item "master:\content\Home" }
Stop-ScriptSession -Session $session

The script runs without an error, but no text is output.

Things I've tried:

  • I have run this same script (Get-Item "master:\content\Home") in the PowerShell Console inside SPE in Sitecore and I get a result.
  • I have changed the -ConnectionUri to gibberish and confirmed that I do get an error if the URL is incorrect (New-WebServiceProxy : The remote name could not be resolved).
  • I have changed the username and password, too, but I do not receive an error if they are incorrect.
  • I have run Invoke-RemoteScript without a session object (passing in the session parameters to that command) and also do not get an output.

I feel like I'm missing something simple. Anyone have any ideas?

1 Answer 1

4

I solved it. I was missing a couple of key configuration steps:

1. Enable the remoting service in the SPE config

In my App_Config\Include\Cognified.PowerShell.config file, I noticed the following (unrelated elements removed for brevity):

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <powershell>
      <services>
        <remoting enabled="false">
          <authorization>
            <add Permission="Allow" IdentityType="Role" Identity="sitecore\PowerShell Extensions Remoting" />
            <!-- example to disable specific user from an endpoint: -->
            <!--add Permission="Deny" IdentityType="User" Identity="sitecore\admin" /-->
          </authorization>
        </remoting>
      </services>
    </powershell>
  </sitecore>
</configuration>

Changing that enabled="false" to an enabled="true" enabled the service. To do that, I added the following patch config file:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <powershell>
      <services>
        <remoting enabled="true" patch:instead="remoting">
          <authorization>
            <add Permission="Allow" IdentityType="Role" Identity="sitecore\PowerShell Extensions Remoting" />
          </authorization>
        </remoting>
      </services>
    </powershell>
  </sitecore>
</configuration>

2. Give access to remote Sitecore users

Add Sitecore users to the sitecore\PowerShell Extensions Remoting role in User Manager.

7
  • 1
    The security now requires the connecting user to be included in the defined role as of version 4.2. Commented Nov 17, 2016 at 22:00
  • @MichaelWest Is there a way to allow access for all administrators (users with the Is Administrator checkbox checked in their profile)? Commented Nov 17, 2016 at 22:31
  • Yes @Dan, have a look at the github issue for more details. github.com/SitecorePowerShell/Console/issues/715 Commented Nov 17, 2016 at 22:41
  • @MichaelWest I take it it's this line? <add Permission="Allow" IdentityType="Role" Identity="sitecore\IsAdministrator" /> Commented Nov 21, 2016 at 3:51
  • 1
    Yes Dan. That's the magic catch all. I prefer creating a service api account and adding it to the PowerShell Extensions Remoting role. Commented Nov 21, 2016 at 3:54

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.