PowerShell Logo Small

Connect-WSMan



This is the built-in help made by Microsoft for the command 'Connect-WSMan', in PowerShell version 2 - as retrieved from Windows version 'Microsoft® Windows Vista™ Ultimate ' 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 [-ApplicationName <string>] [-ComputerName <string>] [-Port <int>] [-UseSSL] [-Authentication <Authentication>] [-ComputerName <str
ing>] [-Credential <PSCredential>] [-Port <int>] [-SessionOption <hashtable>] [<CommonParameters>]
Connect-WSMan [-ConnectionURI <Uri>] [-Authentication <Authentication>] [-ComputerName <string>] [-Credential <PSCredential>] [-Port <int>] [-Ses
sionOption <hashtable>] [<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. Y
ou can use this cmdlet within the context of the WS-Management provider to connect to the WinRM service on a remote computer. However, you can al
so use this cmdlet to connect to the WinRM service on a remote computer before you change to the WS-Management provider. The remote computer will
appear in the root directory of the WS-Management provider.

For more 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 --------------------------

C:\PS>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



Description
-----------
This command creates a connection to the remote server01 computer.

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








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

C:\PS>$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



Description
-----------
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-Creden
tial 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 rem
ote system server01 using the Administrator credentials.

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








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

C:\PS>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



Description
-----------
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 WS-Management provider to connect to a remote computer, in this case the ser
ver01 computer. However, you can use the cmdlet to establish connections to remote computers before you change to the WS-Management provider. Tho
se connections will appear in the ComputerName list.








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

C:\PS>$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



Description
-----------
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 sessi
on 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-WS
Man connects to the remote server01 computer by using the specified session options.

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