• Home   /  
  • Archive by category "1"

Assignmentcollection

I'm guessing that you are using a regular PowerShell session, probably with the SharePoint snapp-in loaded. And not the 'SharePoint Management Shell'.

With a regular powershell session each command is executed with-in its own thread. And disposable objects, like , are automatically disposed on the end of a thread. Thus what could happen is that the Garbage Collector is quick and disposes your before you execute the next statement.

Disposing does not clear or destroy an object, it just gives an object a chance to close connections, clean up things the GC won't clean up, etc. Most properties will still be available (like ) but actions that require a database connection, like , will error out.

SharePoint Management Shell

The SP Management Shell is just a regular powershell session with this tiny bit of script executed when it loads:

Notice the setting on . With the SP Management Shell you get a sligtly different powershell (in an ugly console). One that reuses the same thread for succesive commands, and thus a PowerShell that won't dispose objects 'behind your back'.

See this blog for more information.

Load , instead of just adding the SnapIn

Tip Use the , which has ThreadReuse on as default. And it is a nice tool for writing and testing scripts.

New-SPClaimsPrincipal

Creates a claims principal.

Syntax

Description

This cmdlet contains more than one parameter set. You may only use parameters from one parameter set, and you may not combine parameters from different parameter sets. For more information about how to use parameter sets, see Cmdlet Parameter Sets (http://go.microsoft.com/fwlink/?LinkID=187810).

The New-SPClaimsPrincipal cmdlet creates a claims principal.

For permissions and the most current information about Windows PowerShell for SharePoint Products, see the online documentation at http://go.microsoft.com/fwlink/p/?LinkId=251831 (http://go.microsoft.com/fwlink/p/?LinkId=251831).

Examples

-------------------------EXAMPLE 1-----------------------------

This example creates a claim principal for a Windows user.

-------------------------EXAMPLE 2-----------------------------

This example creates a claim principal for a Windows group.

-------------------------EXAMPLE 3-----------------------------

This example creates a claim principal for a trusted identity token issuer claim.

-------------------------EXAMPLE 4-----------------------------

This example creates a claim principal for a ASPNet Membership User.

-------------------------EXAMPLE 5-----------------------------

This example creates a claim principal for a ASPNet Role.

-------------------------EXAMPLE 6-----------------------------

This example creates a claim principal for a Basic Claim Role, which is also called an encoded claim).

Required Parameters

-ClaimProvider

{{Fill ClaimProvider Description}}

Type:SPClaimProvider
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server 2010, SharePoint Server 2013, SharePoint Server 2016

-ClaimValue

Specifies the claim value of the claims object. The claims value specifies the user, group, or computer that the claim is authenticating.

The type must be a valid claim value; for example, john@contoso.com.

Type:String
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
Applies to:SharePoint Server 2010, SharePoint Server 2013, SharePoint Server 2016

-EncodedClaim

Converts a simple claim to a full encoded claim.

The type must be a valid claim value; for example, i:001w|redmond\user.

Type:String
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
Applies to:SharePoint Server 2010, SharePoint Server 2013, SharePoint Server 2016

-Identity

Specifies the name of the new claims principal.

The type must be a valid name of a claims principal.

Type:String
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
Applies to:SharePoint Server 2010, SharePoint Server 2013, SharePoint Server 2016

-IdentityType

Specifies the type of the new claims principal.

The type must be one of the following: WindowsSamAccountName, WindowsSecurityGroupSid, FormsUser, FormsRole, or EncodedClaim.

Type:SPIdentifierTypes
Position:2
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server 2010, SharePoint Server 2013, SharePoint Server 2016

-TrustedIdentityTokenIssuer

Specifies the ID of the authentication provider.

The type must be a valid GUID, in the form 12345678-90ab-cdef-1234-567890bcdefgh; or a valid name of an Authentication provider (for example, MyAuthprovider1); or an instance of a valid SPTrustedIdentityTokenIssuer object.

Type:SPTrustedIdentityTokenIssuerPipeBind
Position:2
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server 2010, SharePoint Server 2013, SharePoint Server 2016

Optional Parameters

-AssignmentCollection

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

Type:SPAssignmentCollection
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
Applies to:SharePoint Server 2010, SharePoint Server 2013, SharePoint Server 2016

-ClaimType

Specifies the type of claim to create. The value I indicates a unique user identity claim, and the value C indicates all other claims.

The type must be either of the following values: I or C.

Type:String
Position:2
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server 2010, SharePoint Server 2013, SharePoint Server 2016

-IdentifierClaim

Specifies if the new claim is an identity claim.

Type:SwitchParameter
Position:4
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server 2010, SharePoint Server 2013, SharePoint Server 2016

One thought on “Assignmentcollection

Leave a comment

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *