< Back

New-CimSessionDown

Mon Jan 13, 2020 2:15 am

NAME New-CimSessionDown



SYNOPSIS

Opens a CIM session to a computer, with a fallback from WSMAN to DCOM for older operating systems.





SYNTAX

New-CimSessionDown [[-ComputerName] <String[]>] [[-Credential] <PSCredential>] [-Fresh] [-ForceResolve]

[[-OperationTimeoutSec] <Object>] [<CommonParameters>]





DESCRIPTION

CIM is the preferred method of interacting with WMI on a computer. It can reuse a single session instead of

creaing a new session for each interaction. It can timeout which the built-in WMI functions will not. When

communicating with modern operating systems it is less chatty with a fraction of the number of network roundtrips.



A New-CimSession by default only attempts a WSMAN connection, which is the modern CIM protocol. By using

New-CimSessionDown instead existing connections can be re-used, and an additional check is done to use DCOM if

WSMAN fails. This allows you to use CIM to communicate with all of your Windows estate without building two sets

of CIM and WMI calls.



You should always specify -OperationTimeoutSec on any Get-CimInstance and related calls over a CimSession.





PARAMETERS

-ComputerName <String[]>

The name of the remote computer(s). This parameter accepts pipeline input. The local computer is the default.



Required? false

Position? 1

Default value $env:COMPUTERNAME

Accept pipeline input? true (ByValue, ByPropertyName)

Accept wildcard characters? false



-Credential <PSCredential>

Specifies a user account that has permission to perform this action. The default is the current user.



It's not possible to tell connections apart by credential, so, multiple connections to one server with

different users is not recommended, as the wrong session may be returned.



Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Fresh [<SwitchParameter>]



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-ForceResolve [<SwitchParameter>]

Forces sessions created to the local computer name to resolve and use the FQDN instead of localhost.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-OperationTimeoutSec <Object>

"Robust connection timeout minimum is 180" but that's too long



Required? false

Position? 3

Default value 30

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

String





OUTPUTS

Microsoft.Management.Infrastructure.CimSession





NOTES





The "Down" in New-CimSessionDown stands for "down-level", because it talks to down-level versions of Windows.



Verbose is always explicitly disabled on the New-CimSession call because it returns a useless message of ''.



This function is based largely on work done by Mike F Robbins @ http://mikefrobbins.com



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



PS C:\\>New-CimSessionDown -ComputerName Server1



New-CimSessionDown -ComputerName Server1, Server2



Creates a session to a server, then re-retrieves that existing session, along with a new one.











RELATED LINKS