Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

InitialSessionStateEntryCollection<T> Class

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Provides a collection of session state entries, such as commands, types, formats, and variables, for an InitialSessionState object. This class cannot be inherited. This class is introduced in Windows PowerShell 2.0.

Namespace:   System.Management.Automation.Runspaces
Assembly:  System.Management.Automation (in System.Management.Automation.dll)

System.Object
  System.Management.Automation.Runspaces.InitialSessionStateEntryCollection<T>

public sealed class InitialSessionStateEntryCollection<T> : IEnumerable<T>, 
	IEnumerable
where T : InitialSessionStateEntry

Type Parameters

T

A type parameter that is convertible to an InitialSessionStateEntry.

NameDescription
System_CAPS_pubmethodInitialSessionStateEntryCollection<T>()

Creates a new InitialSessionStateEntryCollection<T> object that is empty. This constructor is introduced by Windows PowerShell 2.0.

System_CAPS_pubmethodInitialSessionStateEntryCollection<T>(IEnumerable<T>)

Creates a new InitialSessionStateEntryCollection<T> object that contains session state entries. This constructor is introduced by Windows PowerShell 2.0.

NameDescription
System_CAPS_pubpropertyCount

Gets the number of session state entries in the collection. This property is introduced in Windows PowerShell 2.0.

System_CAPS_pubpropertyItem[Int32]

Gets a session state entry from the collection based on its location. This property is introduced in Windows PowerShell 2.0.

System_CAPS_pubpropertyItem[String]

Gets a session state entry from the collection based on its name. This property is introduced in Windows PowerShell 2.0.

NameDescription
System_CAPS_pubmethodAdd(T)

Adds a session state entry to the collection. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodAdd(IEnumerable<T>)

Adds one or more session state entries to the collection. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodClear()

Clears the collection of all session state entries. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodClone()

Creates an exact copy of the current InitialSessionStateEntryCollection<T> object. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodRemove(String, Object)

Removes a session state entry from the collection based on the entry name and type. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodRemoveItem(Int32)

Removes a session state entry from the collection based on its location. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodRemoveItem(Int32, Int32)

Removes one or more session state entries from the collection, beginning at a specified location. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodReset()

Clears the collection. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubmethodToString()

(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable<T>.GetEnumerator()

Returns a generic enumerator that can iterate through the collection. This method is introduced in Windows PowerShell 2.0.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable.GetEnumerator()

Returns an enumerator that can be used to iterate through the collection. This method is introduced in Windows PowerShell 2.0.

This collection is used by several properties of the InitialSessionState class, such as the Variables property that defines the variables of the initial session state.

A Windows PowerShell 2.0 example that shows how to add two variables to the initial session state.

// Using an InitialSessionState object, create the 
// default initial session state, define variables
// test1 and test2, and add them to the initial session state.
InitialSessionState iss = InitialSessionState.CreateDefault();
SessionStateVariableEntry var1 = new 
    SessionStateVariableEntry("test1",
                              "MyVar1",
                              "Initial session state test");
SessionStateVariableEntry var2 = new 
    SessionStateVariableEntry("test2",
                              "MyVar2",
                              "Initial session state test");
iss.Variables.Add(var1);
iss.Variables.Add(var2);

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: