Delen via


New-PSTransportOption

Hiermee maakt u een object met geavanceerde opties voor een sessieconfiguratie.

Syntaxis

New-PSTransportOption
   [-MaxIdleTimeoutSec <Int32>]
   [-ProcessIdleTimeoutSec <Int32>]
   [-MaxSessions <Int32>]
   [-MaxConcurrentCommandsPerSession <Int32>]
   [-MaxSessionsPerUser <Int32>]
   [-MaxMemoryPerSessionMB <Int32>]
   [-MaxProcessesPerSession <Int32>]
   [-MaxConcurrentUsers <Int32>]
   [-IdleTimeoutSec <Int32>]
   [-OutputBufferingMode <OutputBufferingMode>]
   [<CommonParameters>]

Description

De cmdlet New-PSTransportOption maakt een object met transportopties voor sessieconfiguraties. U kunt het object gebruiken als de waarde van de TransportOption parameter van cmdlets die een sessieconfiguratie maken of wijzigen, zoals de Register-PSSessionConfiguration en Set-PSSessionConfiguration cmdlets.

U kunt ook de transportoptie-instellingen wijzigen door de waarden van de eigenschappen van de sessieconfiguratie in het station WSMan: te bewerken. Zie WSMan Provider voor meer informatie.

De sessieconfiguratieopties vertegenwoordigen de sessiewaarden die zijn ingesteld aan de serverzijde of het ontvangen van het einde van een externe verbinding. De clientzijde, of het verzenden van het einde van de verbinding, kan waarden voor sessieopties instellen wanneer de sessie wordt gemaakt, of wanneer de client verbinding met de sessie verbreekt of opnieuw verbinding maakt. Tenzij anders vermeld, hebben de waarden aan de clientzijde voorrang wanneer de instellingswaarden conflicteren. De waarden aan de clientzijde kunnen echter geen inbreuk maken op de maximumwaarden en quota die zijn ingesteld in de sessieconfiguratie.

Zonder parameters genereert New-PSTransportOption- een transportoptieobject met null-waarden voor alle opties. Als u een parameter weglaat, heeft het object een null-waarde voor de eigenschap die de parameter vertegenwoordigt. Een null-waarde heeft geen invloed op de sessieconfiguratie.

Zie New-PSSessionOption voor meer informatie over sessieopties. Zie about_Session_Configurationsvoor meer informatie over sessieconfiguraties.

Deze cmdlet is geïntroduceerd in Windows PowerShell 3.0.

Voorbeelden

Voorbeeld 1: Een standaard transportoptie genereren

PS C:\> New-PSTransportOption
ProcessIdleTimeoutSec           :
MaxIdleTimeoutSec               :
MaxSessions                     :
MaxConcurrentCommandsPerSession :
MaxSessionsPerUser              :
MaxMemoryPerSessionMB           :
MaxProcessesPerSession          :
MaxConcurrentUsers              :
IdleTimeoutSec                  :
OutputBufferingMode             :

Met deze opdracht wordt de New-PSTransportOption- zonder parameters uitgevoerd. In de uitvoer ziet u dat de cmdlet een transportoptieobject genereert met null-waarden voor alle eigenschappen.

Voorbeeld 2: Opties voor sessieconfiguratie ophalen

The first command uses the **New-PSTransportOption** cmdlet to create a transport options object, which it saves in the $t variable. The command uses the *MaxSessions* parameter to increase the maximum number of sessions to 40.
PS C:\> $t = New-PSTransportOption -MaxSessions 40

The second command uses the **Register-PSSessionConfiguration** cmdlet create the ITTasks session configuration. The command uses the *TransportOption* parameter to specify the transport options object in the $t variable.
PS C:\> Register-PSSessionConfiguration -Name ITTasks -TransportOption $t

The third command uses the Get-PSSessionConfiguration cmdlet to get the ITTasks session configurations and the Format-List cmdlet to display all of the properties of the session configuration object in a list. The output shows that the value of the **MaxShells** property of the session configuration is 40.
PS C:\> Get-PSSessionConfiguration -Name ITTasks | Format-List -Property *
Architecture                  : 64
Filename                      : %windir%\system32\pwrshplugin.dll
ResourceUri                   : https://schemas.microsoft.com/powershell/ITTasks
MaxConcurrentCommandsPerShell : 1000
UseSharedProcess              : false
ProcessIdleTimeoutSec         : 0
xmlns                         : https://schemas.microsoft.com/wbem/wsman/1/config/PluginConfiguration
MaxConcurrentUsers            : 5
lang                          : en-US
SupportsOptions               : true
ExactMatch                    : true
RunAsUser                     :
IdleTimeoutms                 : 7200000
PSVersion                     : 3.0
OutputBufferingMode           : Block
AutoRestart                   : false
MaxShells                     : 40
MaxMemoryPerShellMB           : 1024
MaxIdleTimeoutms              : 43200000
SDKVersion                    : 2
Name                          : ITTasks
XmlRenderingType              : text
Capability                    : {Shell}
RunAsPassword                 :
MaxProcessesPerShell          : 15
Enabled                       : True
MaxShellsPerUser              : 25
Permission                    :

In dit voorbeeld ziet u hoe u een transportoptiesobject gebruikt om opties voor sessieconfiguratie in te stellen.

Voorbeeld 3: Een transportoptie instellen

The first command uses the **New-PSTransportOption** cmdlet to create a transport option object. The command uses the *IdleTimeoutSec* parameter to set the **IdleTimeoutSec** property value of the object to one hour (3600 seconds). The command saves the transport objects object in the $t variable.
PS C:\> $t = New-PSTransportOption -IdleTimeoutSec 3600

The second command uses the Set-PSSessionConfiguration cmdlet to change the transport options of the ITTasks session configuration. The command uses the *TransportOption* parameter to specify the transport options object in the $t variable.
PS C:\> Set-PSSessionConfiguration -Name ITTasks -TransportOption $t

The third command uses the New-PSSession cmdlet to create the MyITTasks session on the local computer. The command uses the **ConfigurationName** property to specify the ITTasks session configuration. The command saves the session in the $s variable.Notice that the command does not use the *SessionOption* parameter of **New-PSSession** to set a custom idle time-out for the session. If it did, the idle time-out value set in the session option would take precedence over the idle time-out set in the session configuration.
PS C:\> $s = New-PSSession -Name MyITTasks -ConfigurationName ITTasks

The fourth command uses the Format-List cmdlet to display all properties of the session in the $s variable in a list. The output shows that the session has an idle time-out of one hour (360,000 milliseconds).
PS C:\> $s | Format-List -Property *
State                  : Opened
IdleTimeout            : 3600000
OutputBufferingMode    : Block
ComputerName           : localhost
ConfigurationName      : ITTasks
InstanceId             : 4110c3f5-68ea-40fa-9bbf-04a433dbb02d
Id                     : 1
Name                   : MyITTasks
Availability           : Available
ApplicationPrivateData : {PSVersionTable}
Runspace               : System.Management.Automation.RemoteRunspace

Met deze opdracht wordt het effect weergegeven van het instellen van een transportoptie in een sessieconfiguratie op de sessies die gebruikmaken van de sessieconfiguratie.

Parameters

-IdleTimeoutSec

Bepaalt hoelang elke sessie open blijft als de externe computer geen communicatie van de lokale computer ontvangt. Dit omvat het heartbeatsignaal. Wanneer het interval verloopt, wordt de sessie gesloten.

De time-outwaarde voor inactiviteit is van groot belang wanneer de gebruiker de verbinding met een sessie wil verbreken en opnieuw verbinding wil maken. De gebruiker kan alleen opnieuw verbinding maken als er geen time-out optreedt voor de sessie.

De parameter IdleTimeoutSec komt overeen met de eigenschap IdleTimeoutMs van een sessieconfiguratie.

Voer een waarde in seconden in. De standaardwaarde is 7200 (2 uur). De minimumwaarde is 60 (1 minuut). Het maximum is de waarde van de eigenschap IdleTimeout van Shell-objecten in de WSMan-configuratie (WSMan:\\\<ComputerName\>\Shell\IdleTimeout). De standaardwaarde is 7200000 milliseconden (2 uur).

Als een time-outwaarde voor inactiviteit is ingesteld in de sessieopties en in de sessieconfiguratie, heeft de waarde die is ingesteld in de sessieopties voorrang, maar kan deze niet groter zijn dan de waarde van de MaxIdleTimeoutMs eigenschap van de sessieconfiguratie. Als u de waarde van de eigenschap MaxIdleTimeoutMs wilt instellen, gebruikt u de parameter MaxIdleTimeoutSec.

Type:Int32
Position:Named
Default value:None
Vereist:False
Pijplijninvoer accepteren:True
Jokertekens accepteren:False

-MaxConcurrentCommandsPerSession

Beperkt het aantal opdrachten dat tegelijkertijd in elke sessie kan worden uitgevoerd tot de opgegeven waarde. De standaardwaarde is 1000.

De parameter MaxConcurrentCommandsPerSession komt overeen met de eigenschap MaxConcurrentCommandsPerShell eigenschap van een sessieconfiguratie.

Type:Int32
Position:Named
Default value:None
Vereist:False
Pijplijninvoer accepteren:True
Jokertekens accepteren:False

-MaxConcurrentUsers

Hiermee beperkt u het aantal gebruikers dat opdrachten tegelijk in elke sessie kan uitvoeren tot de opgegeven waarde. De standaardwaarde is 5.

Type:Int32
Position:Named
Default value:None
Vereist:False
Pijplijninvoer accepteren:True
Jokertekens accepteren:False

-MaxIdleTimeoutSec

Hiermee wordt de time-out voor inactiviteit voor elke sessie beperkt tot de opgegeven waarde. De standaardwaarde is [Int]::MaxValue (~25 dagen).

De time-outwaarde voor inactiviteit is van groot belang wanneer de gebruiker de verbinding met een sessie wil verbreken en opnieuw verbinding wil maken. De gebruiker kan alleen opnieuw verbinding maken als er geen time-out optreedt voor de sessie.

De parameter MaxIdleTimeoutSec komt overeen met de eigenschap MaxIdleTimeoutMs van een sessieconfiguratie.

Type:Int32
Position:Named
Default value:None
Vereist:False
Pijplijninvoer accepteren:True
Jokertekens accepteren:False

-MaxMemoryPerSessionMB

Beperkt het geheugen dat door elke sessie wordt gebruikt tot de opgegeven waarde. Voer een waarde in megabytes in. De standaardwaarde is 1024 megabytes (1 GB).

De parameter MaxMemoryPerSessionMB komt overeen met de eigenschap MaxMemoryPerShellMB van een sessieconfiguratie.

Type:Int32
Position:Named
Default value:None
Vereist:False
Pijplijninvoer accepteren:True
Jokertekens accepteren:False

-MaxProcessesPerSession

Hiermee beperkt u het aantal processen dat in elke sessie wordt uitgevoerd tot de opgegeven waarde. De standaardwaarde is 15.

De parameter MaxProcessesPerSession komt overeen met de eigenschap MaxProcessesPerShell van een sessieconfiguratie.

Type:Int32
Position:Named
Default value:None
Vereist:False
Pijplijninvoer accepteren:True
Jokertekens accepteren:False

-MaxSessions

Beperkt het aantal sessies dat gebruikmaakt van de sessieconfiguratie. De standaardwaarde is 25.

De parameter MaxSessions komt overeen met de eigenschap MaxShells van een sessieconfiguratie.

Type:Int32
Position:Named
Default value:None
Vereist:False
Pijplijninvoer accepteren:True
Jokertekens accepteren:False

-MaxSessionsPerUser

Beperkt het aantal sessies dat de sessieconfiguratie gebruikt en wordt uitgevoerd met de referenties van een bepaalde gebruiker tot de opgegeven waarde. De standaardwaarde is 25.

Wanneer u deze waarde opgeeft, moet u er rekening mee houden dat veel gebruikers mogelijk de referenties van een run als gebruiker gebruiken.

De parameter MaxSessionsPerUser komt overeen met de eigenschap MaxShellsPerUser van een sessieconfiguratie.

Type:Int32
Position:Named
Default value:None
Vereist:False
Pijplijninvoer accepteren:True
Jokertekens accepteren:False

-OutputBufferingMode

Bepaalt hoe opdrachtuitvoer wordt beheerd in niet-verbonden sessies wanneer de uitvoerbuffer vol raakt. De acceptabele waarden voor deze parameter zijn:

  • Blokkeren. Wanneer de uitvoerbuffer vol is, wordt de uitvoering onderbroken totdat de buffer leeg is.
  • Druppel. Wanneer de uitvoerbuffer vol is, wordt de uitvoering voortgezet. Wanneer nieuwe uitvoer wordt opgeslagen, wordt de oudste uitvoer verwijderd.
  • Geen. Er is geen uitvoerbuffermodus opgegeven.

De standaardwaarde van de eigenschap OutputBufferingMode van sessies is Blokkeren.

Type:OutputBufferingMode
Geaccepteerde waarden:None, Drop, Block
Position:Named
Default value:None
Vereist:False
Pijplijninvoer accepteren:True
Jokertekens accepteren:False

-ProcessIdleTimeoutSec

Beperkt de time-out voor elk hostproces tot de opgegeven waarde. De standaardwaarde, 0, betekent dat er geen time-outwaarde is voor het proces.

Andere sessieconfiguraties hebben time-outwaarden per proces. De Microsoft.PowerShell.Workflow sessieconfiguratie heeft bijvoorbeeld een time-outwaarde per proces van 28800 seconden (8 uur).

Type:Int32
Position:Named
Default value:None
Vereist:False
Pijplijninvoer accepteren:True
Jokertekens accepteren:False

Invoerwaarden

None

U kunt invoer voor deze cmdlet niet doorsluisen.

Uitvoerwaarden

WSManConfigurationOption

Notities

  • De eigenschappen van een sessieconfiguratieobject variëren met de opties die zijn ingesteld voor de sessieconfiguratie en de waarden van deze opties. Daarnaast hebben sessieconfiguraties die gebruikmaken van een sessieconfiguratiebestand aanvullende eigenschappen.