Sitecore PowerShell extensions - 404 Not found error
I was recently working on a client's project running Sitecore 8.1 Update 3 and I needed to do some bulk item changes. I decided to install the latest Sitecore PowerShell Extensions (4.7.2) to accomplish this task, however, I was not able to get the module working right away.
Even though I was able to open the PowerShell ISE, whenever I opened the PowerShell console, I got a 404 error:
Because of that error, the security prompt asking for my password to elevate the session state never appeared. I verified that the file not found was present in the file system and that the security was correctly set on the affected files/folders.
I thought that one solution could be to completely deactivate the security prompt by modifying the Congnifide.PowerShell.config file:
There are 3 possible values for the elevateAction: Block, Password and Allow. By setting the Console token to Allow, the security prompt will not appear when opening the console and you will be able to execute commands without an elevated session state (This should never be done on production or internet facing environments for security purposes). However, this approach did not work because the main issue was that my Sitecore instance could not hit the PowerShellWebService.asmx service.
A quick inspection of the showconfig allowed me to see what the problem was. It turned out to be the fault of a custom processor and not related to SPE at all! We had a processor that threw a 404 whenever the context item was null for security purposes:
By adding the Sitecore modules path to the excluded paths:
If you run into this 404 error, make sure you don't have a customized component blocking access to the necessary files/folders as it is most likely an issue with your Sitecore instance and not related to SPE.
Even though I was able to open the PowerShell ISE, whenever I opened the PowerShell console, I got a 404 error:
Because of that error, the security prompt asking for my password to elevate the session state never appeared. I verified that the file not found was present in the file system and that the security was correctly set on the affected files/folders.
I thought that one solution could be to completely deactivate the security prompt by modifying the Congnifide.PowerShell.config file:
<token name=”Default” expiration=”00:00:00″ elevationAction=”Block”/>
<token name=”Console” expiration=”00:05:00″ elevationAction=”Password”/>
<token name=”ISE” expiration=”00:05:00″ elevationAction=”Password”/>
<token name=”ItemSave” expiration=”00:05:00″ elevationAction=”Password”/>
There are 3 possible values for the elevateAction: Block, Password and Allow. By setting the Console token to Allow, the security prompt will not appear when opening the console and you will be able to execute commands without an elevated session state (This should never be done on production or internet facing environments for security purposes). However, this approach did not work because the main issue was that my Sitecore instance could not hit the PowerShellWebService.asmx service.
A quick inspection of the showconfig allowed me to see what the problem was. It turned out to be the fault of a custom processor and not related to SPE at all! We had a processor that threw a 404 whenever the context item was null for security purposes:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<sitecore>
<pipelines xdt:Transform="Replace" >
<httpRequestBegin>
<!-- set context item to 404 page item -->
<processor name="ErrorHttpRequestProcessor" type="XXX.XXX.ErrorPage.ErrorHttpRequestProcessor, XXX.XXX">
<ExcludePaths hint="list:AddExcludedPaths">
<path>/api/sitecore/</path>
<path>/sitecore/api/</path>
<path>/api/content/</path>
<path>/content/api/</path>
</ExcludePaths>
</processor>
</httpRequestBegin>
<httpRequestEnd>
<!-- set status code of response to 404 -->
<processor name="Set404Response" type="XXX.XXX.ErrorPage.Set404Response, XXX.XXX" />
</httpRequestEnd>
</pipelines>
</sitecore>
</configuration>
By adding the Sitecore modules path to the excluded paths:
<path>/sitecore modules/</path>
Sitecore was able to access the PowerShellWebService.asmx.If you run into this 404 error, make sure you don't have a customized component blocking access to the necessary files/folders as it is most likely an issue with your Sitecore instance and not related to SPE.
Comments
Post a Comment