external help file | Module Name | online version | schema |
---|---|---|---|
Wsl-help.xml |
Wsl |
2.0.0 |
Starts an interactive session in a WSL distribution.
Enter-WslDistribution [[-Name] <String>] [[-User] <String>] [-WorkingDirectory <String>] [-ShellType <String>]
[-System] [-WhatIf] [-Confirm] [<CommonParameters>]
Enter-WslDistribution -Distribution <WslDistribution> [[-User] <String>] [-WorkingDirectory <String>]
[-ShellType <String>] [-System] [-WhatIf] [-Confirm] [<CommonParameters>]
The Enter-WslDistribution
cmdlet starts an interactive shell in a WSL distribution. During the
session, all commands that you type run inside the WSL distribution. You can have only one
interactive session at a time.
The distribution to enter can be specified by name, or piped in from the Get-WslDistribution
cmdlet. If no distribution is specified, the default distribution will be used.
This cmdlet will throw an exception if executing wsl.exe
failed (e.g. if there is no distribution
with the specified name), or if the session exited with an non-zero exit code.
This cmdlet wraps the functionality of wsl.exe
without specifying a command.
Enter-WslDistribution
This example starts a shell in the default distribution.
Enter-WslDistribution Ubuntu root -WorkingDirectory "~"
This example starts a shell in the distribution named "Ubuntu", using the "root" user. The starting directory will be the Linux user's home directory.
Import-WslDistribution D:\backup\Alpine.tar.gz D:\wsl | Enter-WslDistribution
This example imports a WSL distribution, and immediately starts an interactive session in that distribution.
Specifies the distribution to enter.
Type: WslDistribution
Parameter Sets: Distribution
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
Specifies the name of a distribution to enter. Unlike with other cmdlets in this module, this parameter does not accept wildcards.
Type: String
Parameter Sets: DistributionName
Aliases: DistributionName
Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
Specifies the shell type to use for the interactive session, either Standard
or Login
.
This parameter requires at least WSL version 0.64.1.
Type: String
Parameter Sets: (All)
Aliases: st
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies that the interactive session should use the system distribution.
This parameter requires at least WSL version 0.47.1.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Specifies the Linux user to run the interactive session as. If omitted, the default user for the distribution is used.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies the working directory to use for the session. Use ~
for the Linux user's home path. If
the path starts with a /
character, it will be interpreted as an absolute Linux path. Otherwise,
the value must be a Windows path.
Type: String
Parameter Sets: (All)
Aliases: wd, cd
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
You can pipe an object retrieved by Get-WslDistribution
to this cmdlet.
You can pipe a distribution name to this cmdlet.