commands

^

Get-DbaCmObject

Author Friedrich Weinmann (@FredWeinmann)
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Get-DbaCmObject on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbaCmObject.

Synopsis

Retrieves Wmi/Cim-Style information from computers.

Description

This function centralizes all requests for information retrieved from Get-WmiObject or Get-CimInstance.
It uses different protocols as available in this order:

  • Cim over WinRM
  • Cim over DCOM
  • Wmi
  • Wmi over PowerShell Remoting
    It remembers channels that didn't work and will henceforth avoid them. It remembers invalid credentials and will avoid reusing them.
    Much of its behavior can be configured using Test-DbaCmConnection.

Syntax

Get-DbaCmObject
    [-ClassName] <String>
    [-ComputerName <DbaCmConnectionParameter[]>]
    [-Credential <PSCredential>]
    [-Namespace <String>]
    [-DoNotUse {None | CimRM | CimDCOM | Wmi | PowerShellRemoting}]
    [-Force]
    [-SilentlyContinue]
    [-EnableException]
    [<CommonParameters>]

Get-DbaCmObject -Query <String>
    [-ComputerName <DbaCmConnectionParameter[]>]
    [-Credential <PSCredential>]
    [-Namespace <String>]
    [-DoNotUse {None | CimRM | CimDCOM | Wmi | PowerShellRemoting}]
    [-Force]
    [-SilentlyContinue]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaCmObject win32_OperatingSystem

Retrieves the common operating system information from the local computer.

Example: 2
PS C:\> Get-DbaCmObject -Computername "sql2014" -ClassName Win32_OperatingSystem -Credential $cred -DoNotUse CimRM

Retrieves the common operating system information from the server sql2014.
It will use the Credentials stored in $cred to connect, unless they are known to not work, in which case they will default to windows credentials (unless another default has been set).

Required Parameters

-ClassName

The name of the class to retrieve.

Alias Class
Required True
Pipeline false
Default Value
-Query

The Wmi/Cim query to run against the server.

Alias
Required True
Pipeline false
Default Value

Optional Parameters

-ComputerName

The computer(s) to connect to. Defaults to localhost.

Alias
Required False
Pipeline true (ByValue)
Default Value $env:COMPUTERNAME
-Credential

Credentials to use. Invalid credentials will be stored in a credentials cache and not be reused.

Alias
Required False
Pipeline false
Default Value
-Namespace

The namespace of the class to use.

Alias
Required False
Pipeline false
Default Value root\cimv2
-DoNotUse

Connection Protocols that should not be used.

Alias
Required False
Pipeline false
Default Value None
-Force

Overrides some checks that might otherwise halt execution as a precaution

  • Ignores timeout on bad connections
Alias
Required False
Pipeline false
Default Value False
-SilentlyContinue

Use in conjunction with the -EnableException switch.
By default, Get-DbaCmObject will throw a terminating exception when connecting to a target is impossible in exception enabled mode.
Setting this switch will cause it write a non-terminating exception and continue with the next computer.

Alias
Required False
Pipeline false
Default Value False
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False