Last active
December 5, 2019 06:41
-
-
Save vtml/4140a4784b55534eba2600bc8ca6179c to your computer and use it in GitHub Desktop.
Running RestfulV2 Powershell Scripts using Query String Authentication for Sitecore Powershell Extensions 5.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
This script triggers any SPE scripts that are available to be used through the Restful V2 service. Sitecore Powershell Extensions 5.0 is required. Please use RestfulV2-BasicAuth.ps1 instead if Sitecore Powershell Extensions 5.1 or above is installed in the Sitecore Instance. | |
.DESCRIPTION | |
This script triggers any SPE scripts that are available to be used through the Restful V2 service. Sitecore Powershell Extensions 5.0 is required. Please use RestfulV2-BasicAuth.ps1 instead if Sitecore Powershell Extensions 5.1 or above is installed in the Sitecore Instance. This can be used on developer PC's, as well as during CI / CD process. RestfulV2 must be enabled in Sitecore Powershell Extensions for this to work. https://doc.sitecorepowershell.com/security | |
For Sitecore 9.1 and above that uses the Identity Server, Cognified.PowerShell.IdentityServer.config must be enabled. This config patch is available from SPE 5.1 and above. | |
.PARAMETER Username | |
The Sitecore username. Uses sitecore\admin by default. | |
.PARAMETER Password | |
The Sitecore user's password. Uses 'b' by default, because 'b' is cool. | |
.PARAMETER SitecoreHost | |
The Content Management Sitecore Host. eg. https://sc911xc91xp0.dev.local | |
.PARAMETER ScriptSitecoreHost | |
The SPE script located within /sitecore/system/Modules/PowerShell/Script Library | |
.PARAMETER Parameters | |
Powershell parameters to be executed against | |
.INPUTS | |
None. | |
.OUTPUTS | |
None. | |
.EXAMPLE | |
PS> .\RestfulV2-QueryStringAuth.ps1 -SitecoreHost https://sc911xc91xp0.dev.local -ScriptSitecorePath /ce-import -Parameters offset=3&limit=2&fields=(Name,ItemPath,Id) | |
#> | |
param( | |
[string] $Username = "sitecore\admin", | |
[string] $Password = "b", | |
[Parameter(Mandatory=$true)] | |
[string] $SitecoreHost, | |
[Parameter(Mandatory=$true)] | |
[string] $ScriptSitecorePath, | |
[string] $Parameters | |
) | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
$url = ("$SitecoreHost/-/script/v2/master{0}?user={1}&password={2}&{3}" -f $ScriptSitecorePath, $Username, $Password, $Parameters) | |
Write-Host $url | |
Invoke-WebRequest -URI $url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment