I have been recently started working with Sitecore and Sitecore PowerShell Extensions, but have been struggling for a while. On my local clean instance of Sitecore, I have installed the SPE package that will allow me to use PowerShell within Sitecore. When I log in to the Experience platform and choose PowerShell ISE from the menu, I can for example run the following script:
Get-User -id admin
and successfully get the result out of it.
From the official Github repository of SPE I have downloaded the latest release (currently it is 4.7). Then, I have created the following PowerShell script (locally, in Windows PowerShell ISE, not in Sitecore):
[CmdletBinding()]
param ()
begin {
[System.String] $SitecoreExtensionsModule = $null
# Initialize command and script root paths.
if (-not $PSCommandPath) { $SCRIPT:PSCommandPath = $SCRIPT:MyInvocation.MyCommand.Path }
if (-not $PSScriptRoot) { $SCRIPT:PSScriptRoot = Split-Path -Path $PSCommandPath -Parent }
$SCRIPT:PSCommandName = Split-Path -Path $PSCommandPath -Leaf
# Initialize the Sitecore PowerShell Extensions module.
if (([System.String]::IsNullOrEmpty($SitecoreExtensionsModule)) -or
(-not (Test-Path -Path $SitecoreExtensionsModule -PathType Leaf))) {
$SitecoreExtensionsModule = Join-Path -Path $PSScriptRoot -ChildPath '.\SPE'
}
Import-Module -Name $SitecoreExtensionsModule -DisableNameChecking -Force -Verbose:$false -ErrorAction Stop
}
process {
# Documentation example from SPE.
$session = New-ScriptSession -Username admin -Password b -ConnectionUri http://sitecoretest:8080 -Timeout ([int]::MaxValue)
$session
Invoke-RemoteScript -Session $session -ScriptBlock { Get-User -id admin } -Verbose
Stop-ScriptSession -Session $session
}
When I run this script, it gives me the following errors:
Set accessor for property "Proxy" is unavailable.
At U:\PowerShell scripts\SPE\Invoke-RemoteScript.ps1:250 char:17
+ ... $singleConnection.Proxy = New-WebServiceProxy @proxyProps ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueException
+ FullyQualifiedErrorId : SetWithoutSetterFromScriptProperty
Set accessor for property "Proxy" is unavailable.
At U:\PowerShell scripts\SPE\Stop-ScriptSession.ps1:102 char:13
+ $singleConnection.Proxy = New-WebServiceProxy @proxyProps
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueException
+ FullyQualifiedErrorId : SetWithoutSetterFromScriptProperty
Invoke-RemoteScript.ps1
and Stop-ScriptSession.ps1
are part of the SPE source code, thus I have no idea why is this error happening. I have been searching over the StackExchange network and also within the issues in the Github repository of the project. Have not found a single thread where someone is asking about such issue, thus I have no idea how to proceed. I have also downloaded previous versions of SPE, like 4.0 and 3.3, but the same error pops up again.
Any help or advise on this is much appreciated. Thanks!