PowerShell Logo Small

New-CimSession



This is the built-in help made by Microsoft for the command 'New-CimSession', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 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

Creates a CIM session.

SYNTAX


New-CimSession [[-ComputerName] <String[]>] [[-Credential] <PSCredential>] [-Authentication <PasswordAuthenticationMechanism>] [-Name <String>] [-OperationTimeoutSec
<UInt32>] [-Port <UInt32>] [-SessionOption <CimSessionOptions>] [-SkipTestConnection] [<CommonParameters>]
New-CimSession [[-ComputerName] <String[]>] [-CertificateThumbprint <String>] [-Name <String>] [-OperationTimeoutSec <UInt32>] [-Port <UInt32>] [-SessionOption
<CimSessionOptions>] [-SkipTestConnection] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The New-CimSession cmdlet creates a CIM session. A CIM session is a client-side object representing a connection to a local computer or a remote computer. The CIM session
contains information about the connection, such as ComputerName, the protocol used for the connection, session ID and instance ID.


This cmdlet returns a CIM session object that can be used by all other CIM cmdlets.



<

RELATED LINKS

Get-ChildItem
Get-Credential
Get-Item
Get-CimSession
Remove-CimSession
New-CimSessionOption

REMARKS

<

Examples


Example 1: Create a CIM session with default options

PS C:\> New-CimSession



This command creates a local CIM session with default options. If ComputerName is not specified, New-CimSession creates a DCOM session to the local computer.






Example 2: Create a CIM session to a specific computer

PS C:\> New-CimSession -ComputerName Server01



This command creates a CIM session to the computer specified by ComputerName. By default, New-CimSession creates a WsMan session when ComputerName is specified.






Example 3: Create a CIM session to multiple computers

PS C:\>New-CimSession -ComputerName Server01,Server02,Server03



This command creates a CIM session to each of the computers specified by ComputerName, in the comma separated list.






Example 4: Create a CIM session with a friendly name

Then you can use the friendly name of a CIM session to easily refer to the session in other CIM cmdlets, for example, Get-CimSession.
PS C:\>New-CimSession -ComputerName Server01,Server02 -Name FileServers



PS C:\>Get-CimSession -Name File*



This command creates a remote CIM session on each of the computer specified by ComptuerName, in the comma separated list, and assigns a friendly name to the new sessions, by
specifying Name.






Example 5: Create a CIM session to a computer using a PSCredential object

PS C:\>New-CimSession -ComputerName Server01 -Credential $cred -Authentication Negotiate



This command creates a CIM session to the computer specified by ComputerName, using the PSCredential object specified by Credential, and the authentication type specified by
Authentication.

You can create a PSCredential object by using the Get-Credential cmdlet.






Example 6: Create a CIM session to a computer using a specific port

PS C:\>New-CimSession -ComputerName Server01 -Port 1234



This command creates a CIM session to the computer specified by ComputerName using the TCP port specified by Port.






Example 7: Create a CIM session using DCOM

PS C:\>$so = New-CimSessionOption -Protocol DCOM



PS C:\>New-CimSession -ComputerName Server1 -SessionOption $so



This command creates a CIM session by using the Distributed COM (DCOM) protocol instead of WSMan.