problem with Set-WSS-Contact-List-From-ActiveDirectory and SharePoint Foundation 2010

Sep 23, 2010 at 9:07 AM

Hello,

I'm trying to use Set-WSS-Contact-List-From-ActiveDirectory to sync user information from AD to a Sharepoint Contact List using SharePoint Foundation 2010.

Doing this I get this error:

New-Object : Exception calling ".ctor" with "1" argument(s): "The Web application at http://servername/ could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application."
At C:\Tools\Set-WSS-Contact-List-From-ActiveDirectory.ps1:156 char:23
+     $Thesite = new-object <<<<  Microsoft.SharePoint.SPSite($WebURL)
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

I give the application name exaclty as shown in Web Applications Management as http://servername/ . If I type the url into a browser it works fine, also when I try this with the same user that runs the Powershell srcipt.

Is this script incompatible with SharePoint Foundation 2010 or do I make a mistake?

Any help would be very appreciated.

Coordinator
Nov 25, 2010 at 2:21 PM

Dear,

This script is designed for SharePoint 2007. I didn't try it on SharePoint 2010 farm, but i will when i can.

I will post the new version for SharePoint 2010 when it will by available.

Thanks for your message

Fabrice Romelard [MVP]

Nov 26, 2010 at 6:56 AM

The error must be caused by lack of Shell Admin permission. Your Farm admin must run Add-SPShellAdmin for your user account to be able to run scripts that access the SharePoint Server Object Model.

Nov 26, 2010 at 6:56 AM
Edited Nov 26, 2010 at 6:59 AM

The cmdlet I mentioned adds the user to the SharePoint_Shell_Access role for the given SharePoint database.

 Add-SPShellAdmin [-UserName] <String> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>] ] [-database <SPDatabasePipeBind>] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]

Coordinator
Nov 26, 2010 at 8:56 AM

Thanks for this point.

Fabrice