1

We have a SharePoint 2010 site deployed using powershell. Before running script we have to create a web application and site collection. Then run the script. The script creates groups and lists.

Now, in SP2013, if we run the powershell, then foll code gives error:-

if ($SPWeb.Site.WebApplication.UseClaimsAuthentication){
        $op = New-SPClaimsPrincipal $OwnerName -IdentityType WindowsSamAccountName
        $mp = New-SPClaimsPrincipal $MemberName -IdentityType WindowsSamAccountName
        $owner = $SPWeb | Get-SPUser $op  //error is on this line
        $member = $SPWeb | Get-SPUser $mp
    }
    else {
    $owner = $SPWeb | Get-SPUser $OwnerName
        if ($MemberName) {
            $member = $SPWeb | Get-SPUser $MemberName
        }
    }

Error is:-

Get-SPUser : You must specify a valid user object or user identity.

SharePoint 2010 sites are classic mode authentication and it looks like SharePoint 2013 by default create site as claims mode. I would like to know whether there is any solution to this error.

To resolve it, I have created an Classic mode authentication site in SharePoint 2013 via powershell:-

New-SPWebApplication -Name "My web app" -ApplicationPool "Web app pool1" -AuthenticationMethod "NTLM" -ApplicationPoolAccount (Get-SPManagedAccount "CONTOSO\nash") -Port 7777

When running this command, I get warning as:-

WARNING: The Windows Classic authentication method is deprecated in this release and the default behavior of this cmdlet, which creates Windows Classic based we b application, is obsolete. It is recommended to use Claims authentication methods. You can create a web application that uses Claims authentication method by s pecifying the AuthenticationProvider parameter set in this cmdlet. Refer to the http://go.microsoft.com/fwlink/?LinkId=234549 site for more information. Please note that the default behavior of this cmdlet is expected to change in the future release to create a Claims authentication based web application instead of a W indows Classic based web application.

Once this is done, the powershell code to create lists/groups and deploy webparts runs all well.

  1. Is there any solution for the script throwing error in SP2013, besides having to create the site via powershell as classic mode which is now deprecated?

  2. Is this good practice to create and use classic mode authentication site in SP2013?

1 Answer 1

2

Once you run the script for creating groups and list in classic based SP 2013 site, you can then convert it to use claims authentication using PowerShell:

Convert-SPWebApplication -Identity "http://sp2013demo:100" -To Claims –RetainPermissions -Force
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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