Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

I have followed instructions to install Tridion Powershell modules as per this post: How do I configure or set up the tridion-powershell-modules in PowerShell?.

I have set the Execution Policy to Unrestricted and set the Tridion version to "2011-SP1"

 Set-TridionCoreServiceSettings -version "2011-SP1"

When I try to run Get-TridionItem "tcm:4-2151" I get the following error:

> You cannot call a method on a null-valued expression. At C:\Users\Administrator\Documents\WindowsPowerShell\Modules\Tridion-CoreService\Items.psm1:130 char:26
+             $client.Close <<<< () | Out-Null;
    + CategoryInfo          : InvalidOperation: (Close:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Here is a screenshot: Tridion Powershell error screenshot

Here are my Tridion settings:

PS C:\Users\Administrator> Get-TridionCoreServiceSettings

ModuleVersion  : 1.2.0.0
Version        : 2011-SP1
UserName       : TRIDION\Administrator
AssemblyPath   : C:\Users\Administrator\Documents\WindowsPowerShell\Modules\Tridion-CoreService\Clients\Tridion.Content
             Manager.CoreService.Client.2011sp1.dll
ClassName      : Tridion.ContentManager.CoreService.Client.SessionAwareCoreServiceClient
ConnectionType : Default
HostName       : localhost
EndpointUrl    : http://localhost/webservices/CoreService2011.svc/wsHttp

What is the cause of the problem and how do I resolve it?

-- UPDATE --

I've gotten the latest code as per @Peter's comment and now receive a clear error message:

PS C:\Users\Administrator> Get-TridionItem "tcm:4-2151-16" 
Get-TridionCoreServiceClient : There was no endpoint listening at http://localhost/webservices/CoreService2011.svc/wsHt tp that could accept the message.  This is often caused by an incorrect address or SOAP action. See InnerException, if p resent, for more details. At C:\Users\Administrator\Documents\WindowsPowerShell\Modules\Tridion-CoreService\Items.psm1:116 char:41
+         $client = Get-TridionCoreServiceClient <<<< ;
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-TridionCoreServiceClient

enter image description here

share|improve this question

2 Answers 2

up vote 5 down vote accepted

I think Dominic is right that the code should check if $client is null before calling the Close method. I'll update it in a second. Most likely, you are getting some other error but the finally block throws this exception which masks the original error.

In the future, feel free to add these things as issues on the Google project itself. And if you're not sure if it's just user error, you can always contact me directly first :)

share|improve this answer
1  
Get the latest and try again. Hopefully you will see a more descriptive error. –  Peter Kjaer Mar 21 at 9:59
    
With the before-latest version. I could reproduce the "You cannot call a method on a null-valued expression" error when the configuration was in a state that Get-TridionCoreServiceClient would throw an error. So try if Get-TridionCoreServiceClient throws an error. –  Jan H Mar 21 at 13:36
    
I've updated the question with the clear error message after downloading the latest release. The problem turned out to be that I had to specify my non-default port number in the -hostname. All works beautifully now. –  Nickoli Roussakov Mar 24 at 14:43

It looks like $client isn't there any more. You could confirm this with the following test:

$client -eq $null

It can be as simple a thing as a timeout. Try getting a new $client and see if that works. My own experience is that the client times out pretty quickly, although usually the error is more WCF in style.

share|improve this answer
    
I assume you meant to write "$client -eq $null". –  Peter Kjaer Mar 21 at 7:30
    
Yes indeed, Peter. Thanks. I'll edit the answer. –  Dominic Cronin Mar 21 at 8:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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