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!

up vote 2 down vote accepted

I've managed to reproduce the problem, and after removing Timeout or changing in it to - Timeout 100 resolves the problem. I don't know why does not accept [int]::MaxValue, maybe it is doing overflow.

  • Thanks for this! I have tried your solution out, and it is working. No idea why [int]::MaxValue is causing troubles. – Dejan Stamenov May 31 at 14:07

The reason you get this is because the Timeout value is intended to be in seconds. The proxy timeout being set is in milliseconds. I wrote the code to multiply it by 1000; therefore [int]::MaxValue * 1000 will result in an error.

If you divided by 1000 then you could avoid the error.

I submitted an issue to catch for this.

  • Thanks for the explanation, Michael! As @Aleksandar thought, it is indeed an overflow. I was going through the source code, but somehow missed that multiplication. – Dejan Stamenov Jun 1 at 6:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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