Share via


InitialSessionState Class

Definition

Allows you to define the set of elements that should be present when Session State is created.

public ref class InitialSessionState
public class InitialSessionState
type InitialSessionState = class
Public Class InitialSessionState
Inheritance
InitialSessionState

Constructors

InitialSessionState()

Ctor for Custom-Shell - Do we need this?

Properties

ApartmentState

ApartmentState of the thread used to execute commands.

Assemblies

The list of assemblies to load...

AuthorizationManager

Specifies the authorization manager to be used for this session state instance. If no authorization manager is specified, then the default authorization manager for PowerShell will be used which checks the ExecutionPolicy before running a command.

Commands

List of commands (Alias, Application, Cmdlets, Function, Script) for this entry.

DisableFormatUpdates

If set to true, disables any updates to format table. This includes disabling format table updates through Update-FormatData, Import-Module etc. All the disabling happens silently ie., the user will not get any exception. By default, this is set to False.

EnvironmentVariables
ExecutionPolicy

Specifies the execution policy to be used for this session state instance.

Formats
LanguageMode

Specifies the language mode to be used for this session state instance.

Modules

Imported modules.

Providers
StartupScripts
ThreadOptions

This property determines whether a new thread is created for each invocation of a command.

ThrowOnRunspaceOpenError

If this property is set and there was a runspace creation error, then throw an exception, otherwise just continue creating the runspace even though it may be in an inconsistent state.

TranscriptDirectory

Specifies the directory to be used for collection session transcripts.

Types

List of types to use for this session state instance...

UseFullLanguageModeInDebugger

If true the PowerShell debugger will use FullLanguage mode, otherwise it will use the current language mode.

Variables

Methods

Clone()

Clone this InitialSessionState object. The collections are recursively cloned as well as the elements in the collections. Note however, that the contents of the individual entries are not deep-cloned. This is only an issue for variable entries which may have reference types. These objects will be added by reference rather than by value.

Create()

Creates an empty InitialSessionState object...

Create(String)

Want to get away from SnapIn and console file. Have modules and assemblies instead. Specify the registered SnapIn name or name collection.

Create(String[], PSConsoleLoadException)
CreateDefault()

Creates the default PowerShell one with default cmdlets, provider etc. BuiltIn functions, aliases need to be available through default InitialSessionstate constructor. Need to have this discussion for packaging as well.

CreateDefault2()

Creates the default PowerShell one with default cmdlets, provider etc. The default cmdlets, provider, etc are loaded via Modules. For loading Microsoft.PowerShell.Core module only.

CreateFrom(String, PSConsoleLoadException)
CreateFrom(String[], PSConsoleLoadException)
CreateFromSessionConfigurationFile(String)

Creates an initial session state from a PSSC configuration file.

CreateFromSessionConfigurationFile(String, Func<String,Boolean>)

Creates an initial session state from a PSSC configuration file.

CreateFromSessionConfigurationFile(String, Func<String,Boolean>, Boolean)

Creates an initial session state from a PSSC configuration file.

CreateRestricted(SessionCapabilities)

Creates an InitialSessionState instance that exposes only the minimal set of commands needed by give set of sessionCapabilities. All commands that are not needed are made private in order to minimize the attack surface.

ImportPSModule(IEnumerable<ModuleSpecification>)

Add a list of modules to import when the runspace is created.

ImportPSModule(String[])

Add a list of modules to import when the runspace is created.

ImportPSModulesFromPath(String)

Imports all the modules from the specified module path by default.

ImportPSSnapIn(String, PSSnapInException)
Obsolete.

Need to have SnapIn support till we move to modules.

Applies to