PowerShell Logo Small

Connect-WSMan



This is the built-in help made by Microsoft for the command 'Connect-WSMan', in PowerShell version 3 - as retrieved from Windows version 'Microsoft Windows Server 2012 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Connects to the WinRM service on a remote computer.

SYNTAX


Connect-WSMan [[-ComputerName] <String>] [-ApplicationName <String>] [-Authentication <AuthenticationMechanism>] [-CertificateThumbprint
<String>] [-Credential <PSCredential>] [-OptionSet <Hashtable>] [-Port <Int32>] [-SessionOption <SessionOption>] [-UseSSL [<SwitchParameter>]]
[<CommonParameters>]
Connect-WSMan [-Authentication <AuthenticationMechanism>] [-CertificateThumbprint <String>] [-ConnectionURI <Uri>] [-Credential
<PSCredential>] [-OptionSet <Hashtable>] [-Port <Int32>] [-SessionOption <SessionOption>] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Connect-WSMan cmdlet connects to the WinRM service on a remote computer, and it establishes a persistent connection to the remote
computer. You can use this cmdlet within the context of the WSMan provider to connect to the WinRM service on a remote computer. However, you
can also use this cmdlet to connect to the WinRM service on a remote computer before you change to the WSMan provider. The remote computer
will appear in the root directory of the WSMan provider.


Note: Explicit credentials are required when the client and server computers are in different domains or workgroups.


For information about how to disconnect from the WinRM service on a remote computer, see Disconnect-WSMan.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkId=141437
Disable-WSManCredSSP
Disconnect-WSMan
Enable-WSManCredSSP
Get-WSManCredSSP
Get-WSManInstance
Invoke-WSManAction
New-WSManInstance
New-WSManSessionOption
Remove-WSManInstance
Set-WSManInstance
Set-WSManQuickConfig
Test-WSMan

REMARKS

<

Examples


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

PS C:\> Connect-WSMan -computer server01
PS C:\Users\testuser> cd wsman:
PS WSMan:\>
PS WSMan:\> dir
WSManConfig: Microsoft.WSMan.Management\WSMan::WSMan
ComputerName Type
------------ ----
localhost Container
server01 Container



This command creates a connection to the remote server01 computer.

The Connect-WSMan cmdlet is generally used within the context of the WSMan provider to connect to a remote computer, in this case the server01
computer. However, you can use the cmdlet to establish connections to remote computers before you change to the WSMan provider. Those
connections will appear in the ComputerName list.








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

PS C:\> $cred = Get-Credential Administrator
Connect-WSMan -computer server01 -credential $cred
PS C:\Users\testuser> cd wsman:
PS WSMan:\>
PS WSMan:\> dir
WSManConfig: Microsoft.WSMan.Management\WSMan::WSMan
ComputerName Type
------------ ----
localhost Container
server01 Container



This command creates a connection to the remote system server01 using the Administrator account credentials.

The first command uses the Get-Credential cmdlet to get the Administrator credentials and then stores them in the $cred variable. The
Get-Credential cmdlet prompts the user for a password of username and password. Users are prompted throught a dialog box

or at the command line, depending on system registry settings.

The second command uses the Credential parameter to pass the credentials stored in $cred to Connect-WSMan. Connect-WSMan then connects to the
remote system server01 using the Administrator credentials.

The Connect-WSMan cmdlet is generally used within the context of the WSMan provider to connect to a remote computer, in this case server01.
However, the cmdlet can be used establish connections to remote computers before changing to the WSMan provider and those connections will
show up in the ComputerName list.








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

PS C:\> Connect-WSMan -computer server01 -port 80
PS C:\Users\testuser> cd wsman:
PS WSMan:\>
PS WSMan:\> dir
WSManConfig: Microsoft.WSMan.Management\WSMan::WSMan
ComputerName Type
------------ ----
localhost Container
server01 Container



This command creates a connection to the remote server01 computer over port 80.

The Connect-WSMan cmdlet is generally used within the context of the WSMan provider to connect to a remote computer, in this case the server01
computer. However, you can use the cmdlet to establish connections to remote computers before you change to the WSMan provider. Those
connections will appear in the ComputerName list.








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

PS C:\> $a = New-WSManSessionOption -operationtimeout 30000
Connect-WSMan -computer server01 -sessionoption $a
PS C:\Users\testuser> cd wsman:
PS WSMan:\>
PS WSMan:\> dir
WSManConfig: Microsoft.WSMan.Management\WSMan::WSMan
ComputerName Type
------------ ----
localhost Container
server01 Container



This command creates a connection to the remote server01 computer by using the connection options that are defined in the
New-WSManSessionOption command.

The first command uses the New-WSManSessionOption cmdlet to store a set of connection setting options in the $a variable. In this case, the
session options set a connection time out of 30 seconds (30,000 milliseconds).

The second command uses the SessionOption parameter to pass the credentials that are stored in the $a variable to Connect-WSMan. Then,
Connect-WSMan connects to the remote server01 computer by using the specified session options.

The Connect-WSMan cmdlet is generally used within the context of the WSMan provider to connect to a remote computer, in this case the server01
computer. However, you can use the cmdlet to establish connections to remote computers before you change to the WSMan provider. Those
connections will appear in the ComputerName list.