Get-SCSMClassInstance
Get-SCSMClassInstance
Gets class instances.
Syntax
Parameter Set: Empty
Get-SCSMClassInstance [-ComputerName <String[]> ] [-Credential <PSCredential> ] [-SCSession <Connection[]> ] [ <CommonParameters>]
Parameter Set: FromCriteria
Get-SCSMClassInstance [-Criteria] <EnterpriseManagementObjectCriteria> [-ComputerName <String[]> ] [-Credential <PSCredential> ] [-SCSession <Connection[]> ] [ <CommonParameters>]
Parameter Set: FromEMODisplayNameParameterSetName
Get-SCSMClassInstance [-DisplayName] <String[]> [-ComputerName <String[]> ] [-Credential <PSCredential> ] [-SCSession <Connection[]> ] [ <CommonParameters>]
Parameter Set: FromEMOIdParameterSetName
Get-SCSMClassInstance [-Id] <Guid[]> [-ComputerName <String[]> ] [-Credential <PSCredential> ] [-SCSession <Connection[]> ] [ <CommonParameters>]
Parameter Set: FromEMONameParameterSetName
Get-SCSMClassInstance [-Name] <String[]> [-ComputerName <String[]> ] [-Credential <PSCredential> ] [-SCSession <Connection[]> ] [ <CommonParameters>]
Parameter Set: FromGroup
Get-SCSMClassInstance [-Group] <EnterpriseManagementObject[]> [-ComputerName <String[]> ] [-Credential <PSCredential> ] [-SCSession <Connection[]> ] [ <CommonParameters>]
Parameter Set: FromManagementPackClass
Get-SCSMClassInstance [-Class] <ManagementPackClass[]> [[-Filter] <String> ] [-ComputerName <String[]> ] [-Credential <PSCredential> ] [-SCSession <Connection[]> ] [ <CommonParameters>]
Detailed Description
The Get-SCSMClassInstance cmdlet retrieves class instances.
Parameters
-Class<ManagementPackClass[]>
Specifies the name of one or more classes to retrieve. You can specify a ManagementPackClass object that is returned by the Get-SCClass cmdlet.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
true (ByValue) |
Accept Wildcard Characters? |
false |
-ComputerName<String[]>
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 (.).
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
localhost |
Accept Pipeline Input? |
true (ByValue) |
Accept Wildcard Characters? |
false |
-Credential<PSCredential>
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.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
Current user context |
Accept Pipeline Input? |
true (ByValue) |
Accept Wildcard Characters? |
false |
-Criteria<EnterpriseManagementObjectCriteria>
Specifies a criteria object that restricts the set of class instances that are returned from the management server.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
true (ByValue) |
Accept Wildcard Characters? |
false |
-DisplayName<String[]>
Specifies the display name of the class instance to retrieve.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
true (ByValue) |
Accept Wildcard Characters? |
false |
-Filter<String>
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.
Aliases |
none |
Required? |
false |
Position? |
2 |
Default Value |
none |
Accept Pipeline Input? |
true (ByValue) |
Accept Wildcard Characters? |
false |
-Group<EnterpriseManagementObject[]>
Specifies an instance of a group that contains the class instances to retrieve.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
true (ByValue) |
Accept Wildcard Characters? |
false |
-Id<Guid[]>
Specifies the ID of the class instances to retrieve. This may be a GUID or a string that will be converted to a GUID.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
true (ByValue) |
Accept Wildcard Characters? |
false |
-Name<String[]>
Specifies the name of the class instances to retrieve.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
true (ByValue) |
Accept Wildcard Characters? |
false |
-SCSession<Connection[]>
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.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
true (ByValue) |
Accept Wildcard Characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
Microsoft.EnterpriseManagement.Configuration.ManagementPackClass
You can pipe a class to the Class parameter of the Get-SCSMClassInstance cmdlet.
Outputs
The output type is the type of the objects that the cmdlet emits.
EnterpriseManagementObject#<classtype>
This cmdlet generates an EnterpriseManagementObject#<classtype> object.
Examples
Example 1: Get computers by NetBIOS name
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.
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
Example 2: Get class instances using a filter
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.
PS C:\>Get-SCSMClassInstance -class $class -filter 'NetbiosDomainName -eq "WOODGROVE"'
Example 3: Get all computer objects
This commands retrieve all class instance objects of type Computer from the Service Manager database.
PS C:\>$class = Get-SCSMClass -name microsoft.windows.computer
PS C:\>Get-SCSMClassInstance -class $class|format-table PrincipalName,ObjectStatus,ActiveDirectorySite,NetbiosDomainName