8

I have written the SPE powershell script in my local Sitecore 9.1.1 sandbox environment and trying to execute, it is asking session elevate privilege to enter credentials. Even though I am entering admin credentials I am getting "Could not validate access using the provided credentials" error.

  1. I have verified Cognifide.PowerShell.config is present.
  2. I have enabled the Cognifide.PowerShell.IdentityServer.config since I am using Identity server
  3. SPE version 5.1 which is compatible with Sitecore 9.1.1

enter image description here

7
  • Where are you hosting it? Commented Jun 26, 2020 at 15:00
  • Did you implement a custom provider or using Azure AD? Commented Jun 26, 2020 at 15:37
  • It is in my local sandbox which is installed in my laptop. I am using default "admin" login Commented Jun 29, 2020 at 3:59
  • 1
    @PrabhuRanganathan Did you find a fix for this issue? we are facing the same issue.
    – Bala
    Commented Oct 21, 2020 at 15:47
  • 2
    @Bala - I changed the elevationAction="Allow" for the required tokens under <userAccountControl><tokens> from Cognifide.PowerShell.config to make it work. I am not sure this is the solution for this since this is related to some permission issue. But it worked for me. Commented Nov 11, 2020 at 6:47

1 Answer 1

0

You can achieve this by adding the below config

<configuration xmlns:set="http://www.sitecore.net/xmlconfig/set/">
    <sitecore>
        <powershell>
            <userAccountControl>
                <tokens>
                    <token name="ISE" set:expiration="00:05:00" set:elevationAction="Allow"/>
                </tokens>
            </userAccountControl>
        </powershell>
    </sitecore>
</configuration>

To assure this config file will be loaded after the SPE.config file name it zzz.MyConfig.config. Sitecore loads .configs file in alphabetical sort order so this might solve the issue.

You can also use patch:instead directive like below, but it still has to be loaded after SPE.config file, otherwise your configs will be replaced.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
        <powershell>
            <userAccountControl>
                <tokens>
                    <token name="ISE" expiration="00:05:00" elevationAction="Allow" patch:instead="*[@name='ISE']"/>
                </tokens>
            </userAccountControl>
        </powershell>
    </sitecore>
</configuration>

P.S. The configs that are declared in Layers.config file will be loaded first. For instance, let's say you are working in a helix based solution and you have this code block in your Layers.config file.

<layer name="Custom" includeFolder="/App_Config/Include/">
  <loadOrder>
    <add path="Foundation" type="Folder" />
    <add path="Feature" type="Folder" />
    <add path="Project" type="Folder" />
  </loadOrder>
</layer>

So that, if you are creating your config under Foundation folder and the SPE.config file is not declared in Layers.config file, your config file will be loaded first and the SPE.config file will replace your configuration.

References

https://mskutta.github.io/2017/08/09/sitecore-patchinstead-in-config/

https://doc.sitecore.com/xp/en/developers/82/sitecore-experience-platform/using-patch-files-to-customize-the-sitecore-configuration.html

https://doc.sitecore.com/xp/en/developers/103/platform-administration-and-architecture/use-a-patch-file-to-customize-the-sitecore-configuration.html

https://sitecorepowershell.com/session-state-elevation/

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.