Get-SCSMClassInstance
Gets class instances.
Syntax
Get-SCSMClassInstance
[-SCSession <Connection[]>]
[-ComputerName <String[]>]
[-Credential <PSCredential>]
[<CommonParameters>]
Get-SCSMClassInstance
[-Class] <ManagementPackClass[]>
[[-Filter] <String>]
[-SCSession <Connection[]>]
[-ComputerName <String[]>]
[-Credential <PSCredential>]
[<CommonParameters>]
Get-SCSMClassInstance
[-DisplayName] <String[]>
[-SCSession <Connection[]>]
[-ComputerName <String[]>]
[-Credential <PSCredential>]
[<CommonParameters>]
Get-SCSMClassInstance
[-Name] <String[]>
[-SCSession <Connection[]>]
[-ComputerName <String[]>]
[-Credential <PSCredential>]
[<CommonParameters>]
Get-SCSMClassInstance
[-Group] <EnterpriseManagementObject[]>
[-SCSession <Connection[]>]
[-ComputerName <String[]>]
[-Credential <PSCredential>]
[<CommonParameters>]
Get-SCSMClassInstance
[-Id] <Guid[]>
[-SCSession <Connection[]>]
[-ComputerName <String[]>]
[-Credential <PSCredential>]
[<CommonParameters>]
Get-SCSMClassInstance
[-Criteria] <EnterpriseManagementObjectCriteria>
[-SCSession <Connection[]>]
[-ComputerName <String[]>]
[-Credential <PSCredential>]
[<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 = '<Criteria
>> xmlns="http://Microsoft.EnterpriseManagement.Core.Criteria/"><Reference
>> Id="Microsoft.Windows.Library" Version="{0}" PublicKeyToken="{1}"
>> Alias="myMP"
>>/><Expression><SimpleExpression><ValueExpressionLeft><Property>$Target/Property[Type="myMP!Microsoft.Windows.Computer"]/NetbiosDomainName$</Property></ValueExpressionLeft><Operator>Equal</Operator><ValueExpressionRight><Value>IR2</Value></ValueExpressionRight></SimpleExpression></Expression></Criteria>'
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: | Microsoft.EnterpriseManagement.Configuration.ManagementPackClass[] |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
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: | System.String[] |
Position: | Named |
Default value: | Localhost |
Required: | False |
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: | System.Management.Automation.PSCredential |
Position: | Named |
Default value: | Current user context |
Required: | False |
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: | Microsoft.EnterpriseManagement.Common.EnterpriseManagementObjectCriteria |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DisplayName
Specifies the display name of the class instance to retrieve.
Type: | System.String[] |
Position: | 1 |
Default value: | None |
Required: | True |
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: | System.String |
Position: | 2 |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Group
Specifies an instance of a group that contains the class instances to retrieve.
Type: | Microsoft.EnterpriseManagement.Common.EnterpriseManagementObject[] |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
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: | System.Guid[] |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Name
Specifies the name of the class instances to retrieve.
Type: | System.String[] |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
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: | Microsoft.SystemCenter.Core.Connection.Connection[] |
Position: | Named |
Default value: | None |
Required: | False |
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
This cmdlet generates an EnterpriseManagementObject#<classtype> object.