I am currently writing a Powershell module to provide functions for installing / operating SharePoint 2007.
One of my scripts checks the health of SharePoint servers farm.
So I use Remote Powershell : using New-PSSession.
In my Virtualized test farm (Windows server 2003, same domain, same admin…), the New-PSSession cmdlet failed :

After googling it, the only solution I saw was to use the NoMachineProfile option :
That solved my problem.
Now the problem :
I need to use SharePoint object : SPFarm.Local (on all servers)
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[Microsoft.SharePoint.Administration.SPFarm]::Local
This code works locally (on all servers)
But when I run it remotely (using the NoMachineProfile option), SPFarm.Local is null !
I Suppose (I cannot check it) it is because SharePoint uses some registry values that are not loaded because of the NoMachineProfile option.
So :
1 – Do you think SPFarm.Local is null because of the NoMachineProfile option ?
2 – Do you know how can I solve the first problem without using the -NoMachineProfile option ?
Thx a lot !
I believe your problem is related to the PowerShell Multi-Hop (Diagram below of what a multi-hop operation is) issue Which was discussed here… PowerShell is not able to perform a multi-hop operation by default, because your credential are not being passed to the next server… Since you are trying to contact different SP servers in the farm from a remote host. I would recommend reading the following blog entry related to multi-hop scenarios and following his instructions to correct your issue.
Using CredSSP for multi-hop authentication
http://www.ravichaganti.com/blog/?p=1230
I know this diagram mentions file server but it’s the same basic principle.