< Back
Get-DbaCmObject
Post
NAME Get-DbaCmObject
SYNOPSIS
Retrieves Wmi/Cim-Style information from computers.
SYNTAX
Get-DbaCmObject [-ClassName] <String> [-ComputerName
<Sqlcollaborative.Dbatools.Parameter.DbaCmConnectionParameter[]>] [-Credential <Pscredential>] [-Namespace
<String>] [-DoNotUse <Sqlcollaborative.Dbatools.Connection.ManagementConnectionType[]>] [-Force <Switch>]
[-SilentlyContinue <Switch>] [-EnableException <Switch>] [<CommonParameters>]
Get-DbaCmObject -Query <String> [-ComputerName <Sqlcollaborative.Dbatools.Parameter.DbaCmConnectionParameter[]>]
[-Credential <Pscredential>] [-Namespace <String>] [-DoNotUse
<Sqlcollaborative.Dbatools.Connection.ManagementConnectionType[]>] [-Force <Switch>] [-SilentlyContinue <Switch>]
[-EnableException <Switch>] [<CommonParameters>]
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.
PARAMETERS
-ClassName [<String>]
The name of the class to retrieve.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-ComputerName [<Sqlcollaborative.Dbatools.Parameter.DbaCmConnectionParameter[]>]
The computer(s) to connect to. Defaults to localhost.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Credential [<Pscredential>]
Credentials to use. Invalid credentials will be stored in a credentials cache and not be reused.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-DoNotUse [<Sqlcollaborative.Dbatools.Connection.ManagementConnectionType[]>]
Connection Protocols that should not be used.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Force [<Switch>]
Overrides some checks that might otherwise halt execution as a precaution
- Ignores timeout on bad connections
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Namespace [<String>]
The namespace of the class to use.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Query [<String>]
The Wmi/Cim query to run against the server.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SilentlyContinue [<Switch>]
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.
Required? false
Position? named
Default value
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
OUTPUTS
NOTES
Tags: ComputerManagement, CIM
Author: Friedrich Weinmann (@FredWeinmann)
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- 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).
RELATED LINKS
https://dbatools.io/Get-DbaCmObject
SYNOPSIS
Retrieves Wmi/Cim-Style information from computers.
SYNTAX
Get-DbaCmObject [-ClassName] <String> [-ComputerName
<Sqlcollaborative.Dbatools.Parameter.DbaCmConnectionParameter[]>] [-Credential <Pscredential>] [-Namespace
<String>] [-DoNotUse <Sqlcollaborative.Dbatools.Connection.ManagementConnectionType[]>] [-Force <Switch>]
[-SilentlyContinue <Switch>] [-EnableException <Switch>] [<CommonParameters>]
Get-DbaCmObject -Query <String> [-ComputerName <Sqlcollaborative.Dbatools.Parameter.DbaCmConnectionParameter[]>]
[-Credential <Pscredential>] [-Namespace <String>] [-DoNotUse
<Sqlcollaborative.Dbatools.Connection.ManagementConnectionType[]>] [-Force <Switch>] [-SilentlyContinue <Switch>]
[-EnableException <Switch>] [<CommonParameters>]
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.
PARAMETERS
-ClassName [<String>]
The name of the class to retrieve.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-ComputerName [<Sqlcollaborative.Dbatools.Parameter.DbaCmConnectionParameter[]>]
The computer(s) to connect to. Defaults to localhost.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Credential [<Pscredential>]
Credentials to use. Invalid credentials will be stored in a credentials cache and not be reused.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-DoNotUse [<Sqlcollaborative.Dbatools.Connection.ManagementConnectionType[]>]
Connection Protocols that should not be used.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Force [<Switch>]
Overrides some checks that might otherwise halt execution as a precaution
- Ignores timeout on bad connections
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Namespace [<String>]
The namespace of the class to use.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Query [<String>]
The Wmi/Cim query to run against the server.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SilentlyContinue [<Switch>]
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.
Required? false
Position? named
Default value
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
OUTPUTS
NOTES
Tags: ComputerManagement, CIM
Author: Friedrich Weinmann (@FredWeinmann)
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- 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).
RELATED LINKS
https://dbatools.io/Get-DbaCmObject