1

I’m trying to hit the Sitecore Webservices with the following Script:

The following function comes from Sitecore/system/Modules/PowerShell/Script Library/Platform/Functions/Remoting

function Set-SitecoreConfiguration {
    [CmdletBinding()]
    param(
        [Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$SitecoreHost,

        [Parameter(Position=1, Mandatory=$true, ValueFromPipeline=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$User,

        [Parameter(Position=2, Mandatory=$true, ValueFromPipeline=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$Password
    )
    $URI = $SitecoreHost + "/sitecore%20modules/PowerShell/Services/RemoteAutomation.asmx";
    $GLOBAL:SpeRemoteProxy = New-WebServiceProxy -Uri $URI
    $GLOBAL:SpeRemoteUser = $User;
    $GLOBAL:SpeRemotePassword = $Password;
} 

#Connect to SiteCore utilizing function above
Set-SitecoreConfiguration –SitecoreHost 'http://sitecorehostname' -User 'Admin' –Password 'b'

This fails with a 404. As you can see, the final URI is:

http://sitecorehostname/sitecore%20modules/PowerShell/Services/RemoteAutomation.asmx, which actually does exist in the directory structure of the website.

One directive that sitecorepowershell.gitbooks.io tells you to do is to update the following in C:\inetpub\wwwroot\SiteCoreSite\Website\App_Config\Include\Cognifide.Powershell.config:

(https://sitecorepowershell.gitbooks.io/sitecore-powershell-extensions/content/security.html)

<sitecore>
  <powershell>
    <services>
      <restfulv1 enabled="true" />
      <restfulv2 enabled="true" />
      <remoting enabled="true" />
      <fileDownload enabled="true" />
      <fileUpload enabled="true" />
      <mediaDownload enabled="true" />
      <mediaUpload enabled="true" />
      <handleDownload enabled="true " />
      <client enabled="true" />
      <execution enabled="true" />
    </services>
  </powershell>
</sitecore>

Even so, I get the following Powershell error:

New-WebServiceProxy : The request failed with HTTP status 404: Not Found. At C:\Scripts\SitecoreConnectionPOC.ps1:17 char:30 + $GLOBAL:SpeRemoteProxy = New-WebServiceProxy -Uri $URI + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (http://sitecorehostname...Automation.asmx:Uri) [New-WebServiceProxy], WebException + FullyQualifiedErrorId : WebException,Microsoft.PowerShell.Commands.NewWebServiceProxy

Any idea what the issue might be? Do we need to enable some sort of capability in Sitecore? I have SPE installed, fyi.

1

2 Answers 2

4

I'm guessing that the version of the script stored in SPE is out of date. I'd prefer you not use it anyways.

First download and install the SPE Remoting module from the marketplace; last one in the list.

Remoting Download

Setup instructions on Youtube here.

Then run this script.

Import-Module -Name SPE
$session = New-ScriptSession -Username admin -Password b -ConnectionUri https://remotesitecore
Invoke-RemoteScript -Session $session -ScriptBlock {
        // Do something remotely
}
Stop-ScriptSession -Session $session

Helpful link to book for remoting

2
  • Thank you, Michael! I'll follow these steps, but I have a quick question. I went to marketplace.sitecore.net and typed in SPE Remoting in the module search field and nothing was returned. Am I in the wrong place? Aug 2, 2017 at 17:06
  • It's actually a download available for Sitecore PowerShell Extensions. Aug 2, 2017 at 17:29
0

I was also receiving a 404 message in Powershell ISE within Sitecore. When I looked at my Sitecore log file I could see some nested exceptions including these lines

Exception: System.Web.HttpException
Message: The file '/sitecore modules/powershell/services/404.htm' does not exist.
Source: System.Web

There was a web.config in the sitecore modules\PowerShell\Services directory which included these lines

<!-- Alternative to disabling the Documentation protocol -->
      <!-- https://msdn.microsoft.com/en-us/library/2tyf2t8t(v=vs.100).aspx -->
      <wsdlHelpGenerator href="404.htm"/>

Commenting out the wsdlHelpGenerator line resolved my issue, I was also able to access sitecore%20modules/PowerShell/Services/RemoteAutomation.asmx directly via the browser.

Your Answer

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

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