Get-SCSMClassInstance

Gets class instances.

Syntax

Get-SCSMClassInstance [-Class] <ManagementPackClass[]> [[-Filter] <String>] [-ComputerName <String[]>]
 [-Credential <PSCredential>] [-SCSession <Connection[]>] [<CommonParameters>]
Get-SCSMClassInstance [-Criteria] <EnterpriseManagementObjectCriteria> [-ComputerName <String[]>]
 [-Credential <PSCredential>] [-SCSession <Connection[]>] [<CommonParameters>]
Get-SCSMClassInstance [-DisplayName] <String[]> [-ComputerName <String[]>] [-Credential <PSCredential>]
 [-SCSession <Connection[]>] [<CommonParameters>]
Get-SCSMClassInstance [-Group] <EnterpriseManagementObject[]> [-ComputerName <String[]>]
 [-Credential <PSCredential>] [-SCSession <Connection[]>] [<CommonParameters>]
Get-SCSMClassInstance [-Id] <Guid[]> [-ComputerName <String[]>] [-Credential <PSCredential>]
 [-SCSession <Connection[]>] [<CommonParameters>]
Get-SCSMClassInstance [-Name] <String[]> [-ComputerName <String[]>] [-Credential <PSCredential>]
 [-SCSession <Connection[]>] [<CommonParameters>]

Description

The Get-SCSMClassInstance cmdlet retrieves class instances.

Examples

Example 1: Get computers by NetBIOS name

PS C:\>$MP = Get-SCManagementPack -name "Microsoft.Windows.Library"
PS C:\>$CriteriaFormat = '> xmlns="http://Microsoft.EnterpriseManagement.Core.Criteria/">> Id="Microsoft.Windows.Library" Version="{0}" PublicKeyToken="{1}" 
>> Alias="myMP" 
>>/>$Target/Property[Type="myMP!Microsoft.Windows.Computer"]/NetbiosDomainName$EqualIR2'
PS C:\>$CriteriaType = "Microsoft.EnterpriseManagement.Common.EnterpriseManagementObjectCriteria"
PS C:\>$criteriaString = $criteriaFormat -f $MP.Version, $MP.KeyToken
PS C:\>$class = Get-SCClass -name "microsoft.windows.computer"
PS C:\>$criteria = new-object $CriteriaType $CriteriaString,$class,$class.ManagementGroup
PS C:\>Get-SCSMClassInstance -criteria $criteria

These commands retrieve computers using the criteria of NetbiosDomainName equals WOODGROVE. The first commands define the parameters that are then used in the final Get-SCSMClassInstance cmdlet.

Example 2: Get class instances using a filter

PS C:\>Get-SCSMClassInstance -class $class -filter 'NetbiosDomainName -eq "WOODGROVE"'
PrincipalName                 ObjectStatus ActiveDirectorySite     NetBiosDomainName
-------------                 ------------ -------------------     -----------------
WIN-752HJBSX24M.woodgrove.com Active       Default-First-Site-Name WOODGROVE
JWT-SCDW.woodgrove.com        Active                               WOODGROVE

This command retrieves class instance objects from the Service Manager database using a filter. Note that the property name in the filter must be the exact name of the property and that it is case sensitive.

Example 3: Get all computer objects

PS C:\>$class = Get-SCSMClass -name microsoft.windows.computer
PS C:\>Get-SCSMClassInstance -class $class|format-table PrincipalName,ObjectStatus,ActiveDirectorySite,NetbiosDomainName
PrincipalName                 ObjectStatus ActiveDirectorySite     NetbiosDomainName
-------------                 ------------ -------------------     -----------------
WIN-752HJBSX24M.woodgrove.com Active       Default-First-Site-Name WOODGROVE
JWT-SCDW.woodgrove.com        Active                               WOODGROVE

This commands retrieve all class instance objects of type Computer from the Service Manager database.

Parameters

-Class

Specifies the name of one or more classes to retrieve. You can specify a ManagementPackClass object that is returned by the Get-SCClass cmdlet.

Type:ManagementPackClass[]
Required:True
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-ComputerName

Specifies a computer to establish a connection with. The computer must be running the System Center Data Access service. The default value is the computer for the current management group connection.

Valid formats include a NetBIOS name, an IP address, or a fully qualified domain name (FQDN). To specify the local computer, type the computer name, "localhost", or a dot (.).

Type:String[]
Required:False
Position:Named
Default value:Localhost
Accept pipeline input:False
Accept wildcard characters:False
-Credential

Specifies a user account under which the management group connection will run. The account must have access to the server that is specified in the ComputerName parameter, if the server is specified. The default value is the current user.

You can enter a PSCredential object that is returned by the Get-Credential cmdlet.

Type:PSCredential
Required:False
Position:Named
Default value:Current user context
Accept pipeline input:False
Accept wildcard characters:False
-Criteria

Specifies a criteria object that restricts the set of class instances that are returned from the management server.

Type:EnterpriseManagementObjectCriteria
Required:True
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-DisplayName

Specifies the display name of the class instance to retrieve.

Type:String[]
Required:True
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Filter

Filters the results set. The syntax of the filter is the <property> operator <value>, where valid operators are -eq, -ne, -gt, -ge, -lt, -le, -like, and -notlike. Using a filter is efficient because the filter limits the results that are retrieved from the management server, rather than being applied after the results are returned to PowerShell.

Type:String
Required:False
Position:2
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Group

Specifies an instance of a group that contains the class instances to retrieve.

Type:EnterpriseManagementObject[]
Required:True
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-Id

Specifies the ID of the class instances to retrieve. This may be a GUID or a string that will be converted to a GUID.

Type:Guid[]
Required:True
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-Name

Specifies the name of the class instances to retrieve.

Type:String[]
Required:True
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-SCSession

Specifies a connection to a management server. The default value is the current management group connection.

You can enter a management group connection object that is returned by the Get-SCManagementGroupConnection cmdlet.

Type:Connection[]
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Microsoft.EnterpriseManagement.Configuration.ManagementPackClass

You can pipe a class to the *Class* parameter of the **Get-SCSMClassInstance** cmdlet.

Outputs

EnterpriseManagementObject#<classtype>

This cmdlet generates an **EnterpriseManagementObject#\** object.